After I writing this article, a member asked for something similar
I need a similar button "I want a personalized offer" only in the "horeca" category. I want my clients to ask for personalized offers for larger quantities only in this category. Can you help me?
So I did a function for that
With this feature you can add a button: Request a personalized offer for quantities to your Woocommerce online store only in one category
Go to your template (preferably in your child template)
(You can locate your template directly in the files /wp-content/themes/your-template. Or you can edit directly in wp-admin in Appearance>Theme File Editor>Theme Functions)
Edit "function.php"
Add this function
add_action('woocommerce_after_add_to_cart_button','custom_offer_button');
function custom_offer_button() {
if ( has_term( 'horeca', 'product_cat' ) ) {
global $product;
$product_id = $product->get_id();
$product_url = get_permalink( $product_id ) ;
echo '<a href="https://wa.me/40700000000?text=Hi!%20I%20want%20customized%20offer%20for%20this%20product:%20'.$product_url.'%20for%20a%20quantity%20of:" class="button alt">Request a personalized offer for quantities</a>';
}
}
Change from the above function 40700000000 with your phone number with prefix but without + and horeca with your category
That's it! I hope you succeeded. If you need help leave a comment