get_title() ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">';
}
/**
* Default shop archive card elements.
*/
function botiga_get_default_shop_archive_card_elements() {
$elements = array( 'botiga_shop_loop_product_title', 'woocommerce_template_loop_price' );
/**
* Hook 'botiga_default_shop_archive_card_elements'
* Filters the default shop archive card elements from customizer settings.
*
* @param array $elements Default elements.
*
* @since 2.2.2
*/
return apply_filters( 'botiga_default_shop_archive_card_elements', $elements );
}
/**
* Default single product components
*/
function botiga_get_default_single_product_components() {
$components = array(
'woocommerce_template_single_title',
'woocommerce_template_single_rating',
'woocommerce_template_single_price',
'woocommerce_template_single_excerpt',
'woocommerce_template_single_add_to_cart',
'botiga_divider_output',
'woocommerce_template_single_meta',
);
$wishlist_enable = Botiga_Modules::is_module_active( 'wishlist' );
$wishlist_layout = get_theme_mod( 'shop_product_wishlist_layout', 'layout1' );
if( $wishlist_enable && 'layout1' !== $wishlist_layout ) {
$components[] = 'botiga_single_wishlist_button';
}
/**
* Hook 'botiga_default_single_product_components'
*
* @since 1.0.0
*/
return apply_filters( 'botiga_default_single_product_components', $components );
}
/**
* Single product elements
*/
function botiga_single_product_elements() {
$elements = array(
'woocommerce_template_single_title' => esc_html__( 'Product Title', 'botiga' ),
'woocommerce_template_single_rating' => esc_html__( 'Rating', 'botiga' ),
'woocommerce_template_single_price' => esc_html__( 'Price', 'botiga' ),
'woocommerce_template_single_excerpt' => esc_html__( 'Short Description', 'botiga' ),
'woocommerce_template_single_add_to_cart' => esc_html__( 'Add to Cart', 'botiga' ),
'botiga_divider_output' => esc_Html__( 'Divider', 'botiga' ),
'woocommerce_template_single_meta' => esc_html__( 'Meta', 'botiga' ),
);
$wishlist_enable = Botiga_Modules::is_module_active( 'wishlist' );
$wishlist_layout = get_theme_mod( 'shop_product_wishlist_layout', 'layout1' );
if( $wishlist_enable && 'layout1' !== $wishlist_layout ) {
$elements[ 'botiga_single_wishlist_button' ] = esc_html__( 'Wishlist Button', 'botiga' );
}
/**
* Hook 'botiga_single_product_elements'
*
* @since 1.0.0
*/
return apply_filters( 'botiga_single_product_elements', $elements );
}
/**
* Map and replace default woo template functions with quick view functions
*/
function botiga_get_quick_view_summary_components( $components = array() ) {
$components = array_map( function( $component ){
$suffix = str_replace( 'woocommerce_template_single_', '', $component );
if( $component === "woocommerce_template_single_$suffix" ) {
return "botiga_quick_view_summary_$suffix";
}
return $component;
}, $components );
/**
* Hook 'botiga_quick_view_product_components'
*
* @since 1.0.0
*/
return apply_filters( 'botiga_quick_view_product_components', $components );
}
/**
* Divider output
*/
function botiga_divider_output() {
echo '
';
}
/**
* Botiga output for simple product add to cart area.
* The purpose is avoid third party plugins hooking here
*/
function botiga_simple_add_to_cart( $product, $prefix = '', $remove_botiga_prefix = false ) {
// @codingStandardsIgnoreStart WPThemeReview.CoreFunctionality.PrefixAllGlobals.DynamicHooknameFound
if ( ! $product->is_purchasable() ) {
return;
}
$hook_prefix = botiga_get_hook_prefix( $prefix, $remove_botiga_prefix );
echo wc_get_stock_html( $product ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
do_action( "{$hook_prefix}before_add_to_cart", $product );
if ( $product->is_in_stock() ) : ?>
get_children() ), 'wc_products_array_filter_visible_grouped' );
if ( $products ) :
$post = get_post( $product->get_id() );
$grouped_product = $product;
$grouped_products = $products;
$quantites_required = false;
do_action( "{$hook_prefix}before_add_to_cart_form" ); ?>
get_children() ) <= apply_filters( "{$hook_prefix}ajax_variation_threshold", 30, $product );
$available_variations = $get_variations ? $product->get_available_variations() : false;
$attributes = $product->get_variation_attributes();
$selected_attributes = $product->get_default_attributes();
$attribute_keys = array_keys( $attributes );
$variations_json = wp_json_encode( $available_variations );
$variations_attr = function_exists( 'wc_esc_json' ) ? wc_esc_json( $variations_json ) : _wp_specialchars( $variations_json, ENT_QUOTES, 'UTF-8', true );
do_action( "{$hook_prefix}before_add_to_cart_form" ); ?>
add_to_cart_url() ) {
return;
}
$product_url = $product->add_to_cart_url();
$button_text = $product->single_add_to_cart_text();
$hook_prefix = botiga_get_hook_prefix( $prefix, $remove_botiga_prefix );
do_action( "{$hook_prefix}before_add_to_cart_form" ); ?>
">get_price_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
';
echo wp_kses_post( $html );
echo '';
}
/**
* Single product elements 'Shortcode' output
*/
function botiga_single_product_shortcode() {
$shortcode = get_theme_mod( 'botiga_single_product_shortcode_content', '' );
echo '';
echo do_shortcode( $shortcode );
echo '
';
}
/**
* Render woocommerce breadcrumbs removing the trailing slash.
*/
function botiga_woocommerce_breadcrumbs() {
ob_start();
woocommerce_breadcrumb();
$breadcrumbs = ob_get_clean();
echo wp_kses_post( str_replace( array( ' / ', ' / ' ), array( '', '' ), $breadcrumbs ) );
}
/**
* Render the product archive description.
* For some reason the default WooCommerce 'woocommerce_product_archive_description' function do not
* display the description whether the page has the 'paged' query_var. This function is a workaround
* to display the description in this case.
*
* @since 2.2.6
*
* @return void
*/
function botiga_woocommerce_product_archive_description() {
if ( is_search() ) {
return;
}
if ( is_post_type_archive( 'product' ) ) {
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
$allowed_html = wp_kses_allowed_html( 'post' );
// This is needed for the search product block to work.
$allowed_html = array_merge(
$allowed_html,
array(
'form' => array(
'action' => true,
'accept' => true,
'accept-charset' => true,
'enctype' => true,
'method' => true,
'name' => true,
'target' => true,
),
'input' => array(
'type' => true,
'id' => true,
'class' => true,
'placeholder' => true,
'name' => true,
'value' => true,
),
'button' => array(
'type' => true,
'class' => true,
'label' => true,
),
'svg' => array(
'hidden' => true,
'role' => true,
'focusable' => true,
'xmlns' => true,
'width' => true,
'height' => true,
'viewbox' => true,
),
'path' => array(
'd' => true,
),
)
);
$description = wc_format_content( wp_kses( $shop_page->post_content, $allowed_html ) );
if ( $description ) {
echo '' . $description . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
}
}
/**
* Render the taxonomy archive description.
* For some reason the default WooCommerce 'woocommerce_taxonomy_archive_description' function do not
* display the description whether the page has the 'paged' query_var. This function is a workaround
* to display the description in this case.
*
* @since 2.2.6
*
* @return void
*/
function botiga_woocommerce_taxonomy_archive_description() {
if ( is_product_taxonomy() ) {
$term = get_queried_object();
if ( $term ) {
/**
* Filters the archive's raw description on taxonomy archives.
*
* @since WooCommerce 6.7.0
*
* @param string $term_description Raw description text.
* @param WP_Term $term Term object for this taxonomy archive.
*/
$term_description = apply_filters( 'woocommerce_taxonomy_archive_description_raw', $term->description, $term );
if ( ! empty( $term_description ) ) {
echo '' . wc_format_content( wp_kses_post( $term_description ) ) . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
}
}