WooCommerce Conditional Tag inside plugin

Question

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?

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/woocommerce-conditional-tag-inside-plugin/">

WooCommerce Conditional Tag inside plugin</a>
0
, , Nathan Wilson 2 months 0 Answers 37 views 0

Leave an answer