Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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
You can’t perform that action at this time.