Last active
February 7, 2020 01:47
This file contains 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
// Replace the Add to Cart Btn in Category Firearms with Read More Btn | |
add_filter('woocommerce_loop_add_to_cart_link','change_simple_shop_add_to_cart_btn',10,2); | |
function change_simple_shop_add_to_cart_btn( $html, $product ){ | |
if( $product->is_type('simple')) { | |
$category_name = $product->get_categories(); | |
if (strstr($category_name, 'Firearms')) { // your category name 'Firearms' | |
$html = sprintf( '<a id="read-more-btn-fa" rel="nofollow" href="%s" data-product_id="%s" class="button vp-btn">%s</a>', | |
esc_url( get_the_permalink() ), | |
esc_attr( $product->get_id() ), | |
esc_html( __( 'Read More', 'woocommerce' ) ) | |
); | |
$category_name = $product->get_categories(); | |
} | |
} | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment