Woocommerce: Address one particular category in functions.php
-
Dear gents,
I’m almost ready with my own online shop, but currently struggling with some little problems.
I would like to add a little string above the “put-into-cart”-button to give customers a short information.
After some hours of surching and testing I found this code, which works very well:function customerinfo() { echo '(This product is 0.5 m long.)'; } add_action( 'woocommerce_before_add_to_cart_button', 'customerinfo' );
However, I would like to add this string only for one category, but not for all categories. Therefore, I tried to use:
function customerinfo() { echo '(This product is 0.5 m long.)'; } if ( is_product_category() ) { if ( is_product_category('fabric') ) { add_action( 'woocommerce_before_add_to_cart_button', 'customerinfo' ); }
Anyhow, it doesn’t work. What’s my thinking failure?
Many thanks for any help!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Woocommerce: Address one particular category in functions.php’ is closed to new replies.