'; }, 11 );
add_action( 'woocommerce_after_shop_loop_item', function() { echo '
'; }, PHP_INT_MAX );
// Categories
add_filter( 'subcategory_archive_thumbnail_size', function(){ return 'botiga-big'; } );
add_action( 'woocommerce_before_subcategory', function() use ($loop_image_wrap_extra_class) { echo ''; }, 11 );
add_action( 'woocommerce_after_subcategory', function() { echo '
'; }, PHP_INT_MAX );
}
if ( in_array( $layout, array( 'product-grid', 'product-masonry' ) ) ) {
$shop_woocommerce_catalog_columns_desktop = get_theme_mod( 'shop_woocommerce_catalog_columns_desktop', 4 );
if( $shop_woocommerce_catalog_columns_desktop === 2 ) {
add_filter( 'single_product_archive_thumbnail_size', function(){ return 'botiga-large'; } );
add_filter( 'subcategory_archive_thumbnail_size', function(){ return 'botiga-large'; } );
add_filter( 'woocommerce_get_image_size_botiga-large', function( $size ){ $size[ 'width' ] = 920; return $size; } );
}
if( $shop_woocommerce_catalog_columns_desktop === 1 ) {
add_filter( 'single_product_archive_thumbnail_size', function(){ return 'botiga-extra-large'; } );
add_filter( 'subcategory_archive_thumbnail_size', function(){ return 'botiga-extra-large'; } );
add_filter( 'woocommerce_get_image_size_botiga-extra-large', function( $size ){ $size[ 'width' ] = 1140; return $size; } );
}
}
}
/**
* Loop product structure
*/
//Move link close tag
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 12 );
//Wrap loop image
if ( in_array( $layout, array( 'product-grid', 'product-masonry' ) ) || is_product() ) {
//Wrap loop image
add_action( 'woocommerce_before_shop_loop_item_title', function() use ($loop_image_wrap_extra_class) { echo ''; }, 11 );
}
if ( in_array( $layout, array( 'product-grid', 'product-masonry' ) ) ) {
//Move button inside image wrap
if ( 'layout4' === $button_layout && 'layout3' !== $quick_view_layout || 'layout3' === $button_layout && 'layout2' !== $quick_view_layout ) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
add_action( 'woocommerce_before_shop_loop_item_title', function() { botiga_wrap_loop_button_start(); woocommerce_template_loop_add_to_cart(); echo '
'; } );
}
} else {
//Move button inside image wrap
if ( 'layout4' === $button_layout && 'layout3' !== $quick_view_layout || 'layout3' === $button_layout && 'layout2' !== $quick_view_layout ) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
add_action( 'woocommerce_before_shop_loop_item_title', function() { botiga_wrap_loop_button_start(); woocommerce_template_loop_add_to_cart(); echo ''; } );
}
}
//Remove product title, rating, price
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title' );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price' );
//Add elements from sortable option
add_action( 'woocommerce_after_shop_loop_item', 'botiga_loop_product_structure', 9 );
//Wrap loop button
if ( 'layout4' !== $button_layout ) {
add_action( 'woocommerce_after_shop_loop_item', 'botiga_wrap_loop_button_start', 9 );
add_action( 'woocommerce_after_shop_loop_item', function() { echo ''; }, 11 );
}
//Remove button
if( 'layout1' === $button_layout ) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
//Quick view button & add to cart button
if (
( 'layout4' === $button_layout && 'layout3' === $quick_view_layout ) ||
( 'layout3' === $button_layout && 'layout2' === $quick_view_layout )
) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );
}
//Quick view and wishlist buttons
if ( is_shop() || is_product_category() || is_product_tag() || is_product() || botiga_page_has_woo_blocks() || is_cart() || is_404() || is_product_taxonomy() ) {
if( 'layout1' !== $quick_view_layout || 'layout1' !== $wishlist_layout ) {
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open' );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close' );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_open', 9 );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 11 );
}
if( 'layout1' !== $quick_view_layout ) {
add_action( 'woocommerce_before_shop_loop_item_title', 'botiga_quick_view_button', 10 );
//Quick view popup
add_action( 'wp_body_open', 'botiga_quick_view_popup' );
// Do not include on single product pages
if ( current_theme_supports( 'wc-product-gallery-lightbox' ) && false === is_product() ) {
add_action( 'botiga_footer_after', function(){
wc_get_template( 'single-product/photoswipe.php' );
} );
}
}
if( 'layout1' !== $wishlist_layout ) {
add_action( 'woocommerce_before_shop_loop_item_title', 'botiga_wishlist_button', 10 );
}
}
$shop_cart_show_cross_sell = get_theme_mod( 'shop_cart_show_cross_sell', 1 );
if( $shop_cart_show_cross_sell ) {
//Quick view popup
add_action( 'wp_body_open', 'botiga_quick_view_popup' );
}
// Add to cart button text
add_filter( 'woocommerce_product_add_to_cart_text', 'botiga_add_to_cart_text', 10, 2);
}
add_action( 'wp', 'botiga_product_card_hooks' );
/**
* Loop add to cart
*/
function botiga_filter_loop_add_to_cart( $button, $product, $args ) {
global $product;
//Return if not button layout 4
$button_layout = get_theme_mod( 'shop_product_add_to_cart_layout', 'layout3' );
$layout = get_theme_mod( 'shop_archive_layout', 'product-grid' );
if ( 'layout4' !== $button_layout ) {
return $button;
}
if ( $product->is_type( 'simple' ) ) {
$text = '