Hook that specifies an action code is only applied to a certain product category
-
I have some code running globally on my website that places a notation between my product variation and the add to cart button, however, I do not want it to appear globally, but rather only applied to particular Product Category Slugs or Product ID’s.
I’ve tried what seems like a million different things to make it happen, but the code still appears on every product/category I have published.
The code is as follows:
add_action( ‘woocommerce_before_add_to_cart_button’ , ‘aj_add_below_prod_var’, 5 );
function aj_add_below_prod_var() { echo ‘ Quantities are in HALF YARD increments. (1=1/2 Yard, 2=1 Yard, 3=1 1/2 Yards, etc.) ‘; }
Can anyone help? I only want it to appear on the products that are in the category slug ‘pre-order-fabrics’
Thanks so much for any assistance!
- The topic ‘Hook that specifies an action code is only applied to a certain product category’ is closed to new replies.