Woocommerce: How to change the add to cart text in a certain category? [closed]
You can use the has_term function to check for the desired term. function add_cart_button_replace() { global $product; $link = $product->get_permalink(); $button_text = __(‘+show OFFER’, ‘woocommerce’); // check if the current product has a “product-category” of “free-products” if(has_term(‘free-products’, ‘product_cat’, $product->get_id())) $button_text = __(‘+choose me’, ‘woocommerce’); echo do_shortcode(‘<a href=”‘.$link.'” class=”button addtocartbutton”>’ . $button_text . ‘</a>’); } You … Read more