Answer the question
In order to leave comments, you need to log in
How to display different text under the add_to_cart button for different product categories?
I want to display different text under the buy button, in different categories, on the product page example
add_action( 'woocommerce_after_add_to_cart_button', 'mytext_after_add_to_cart_button', 50);
function mytext_after_add_to_cart_button() {
if( is_product_category( 'coffee' ) ) {
echo '<div class="get-mytext-form"><a href="/mytext-form1/">Need help with form1?</a></div>';
} else {
echo '<div class="get-mytext-form2"><a href="/mytext-form2/">Need help with form2?</a></div>';
}
}
Answer the question
In order to leave comments, you need to log in
https://github.com/woocommerce/woocommerce/blob/ma...
You can hook your function to the woocommerce_single_product_summary hook with a priority of 35 and your label will appear right after the button
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question