Do you have an online store made with WordPress and Woocommerce?

Do you want to add a custom button for your customers to chat directly with you on WhatsApp about a product?

Increase your store conversions by allowing your customers to place orders directly through WhatsApp

In this tutorial I will show you the simplest method to add a button "Order on WhatsApp" for free

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 line

 

add_action('woocommerce_after_add_to_cart_button','whatsapp_button');
function whatsapp_button() {
    global $product;
    $product_id = $product->get_id();
    $product_url = get_permalink( $product_id ) ;
    echo '<a href="https://wa.me/40700000000?text=Hello!%20want%20this%20product:%20'.$product_url.'" style="background: #46c655; color:#fff;" class="button alt"><i class="fab fa-whatsapp"></i> Buy on WhatsApp</a>';
}

 

Change from the above function 40700000000 with your phone number with prefix but without +

 

That's it!

I hope you succeeded. If you need help leave a comment