WooCommerce Conditional Tag inside plugin


I’m writing a small plugin to add some text above the ‘Add To Cart’ button on the WooCommerce product page.

My code:

add_action('woocommerce_before_add_to_cart_button', 'ddd_above_add_to_cart', 100);
function ddd_above_add_to_cart() { 
    if(is_product_category('vss') ) {
        echo 'hello world';

My problem is when I use the conditional tag is_product_category('vss') to display the text based on the product category.
I’m sure this error is occurring as the function is not running inside the loop, but I’m not sure how to change this.

Can anyone help me with this?

, , Nathan Wilson 10 months 0 Answers 66 views 0

Leave an answer