Last active
September 26, 2017 08:14
-
-
Save ahmedeshaan/6fb5650858177b512add27863f9aba9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Add Add to Cart After */ | |
function support_flatsome_woocommerce_shop_loop_button(){ | |
if(flatsome_option('add_to_cart_icon') !== "button") return; | |
global $product; | |
$lists = array(); | |
$terms = get_the_terms($product->get_id(), 'product_cat'); | |
if( !is_wp_error($terms ) ){ | |
foreach ($terms as $term) { | |
array_push( $lists, $term->slug); | |
} | |
if ( in_array('add your category slug here', $lists) ) { | |
return ''; | |
} | |
} | |
$button_style = 'outline'; | |
echo apply_filters( 'woocommerce_loop_add_to_cart_link', | |
sprintf( '<div class="add-to-cart-button"><a href="%s" rel="nofollow" data-product_id="%s" class="%s %s product_type_%s button %s is-%s mb-0 is-%s">%s</a></div>', | |
esc_url( $product->add_to_cart_url() ), | |
esc_attr( $product->get_id() ), | |
esc_attr( $product->is_type( 'variable' ) ? '' : 'ajax_add_to_cart'), | |
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', | |
esc_attr( $product->get_type() ), | |
esc_attr( 'primary' ), // Button color | |
esc_attr( get_theme_mod('add_to_cart_style', 'outline') ), // Button style | |
esc_attr( 'small' ), // Button size | |
esc_html( $product->add_to_cart_text() ) | |
), | |
$product ); | |
} | |
add_action('wp', function(){ | |
remove_action('flatsome_product_box_after', 'flatsome_woocommerce_shop_loop_button', 100); | |
add_action('flatsome_product_box_after', 'support_flatsome_woocommerce_shop_loop_button', 110); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment