I am trying to send the selected variant SKU via my custom built whatsapp button but it’s sending only pre-selected SKU via whatsapp. I want your help to suggest me a proper code snippet to solve this problem.
file name product-template.liquid
The code for variable sku i am using.
{% assign current_variant = product.selected_or_first_available_variant %}
SKU-{{ current_variant.sku }}
The whatsapp button code.
[Buy on Whatsapp](https://wa.me/91XXXXXXXXXX?text={{ current_variant.sku }})
The Problem with this code.
When i open a product page and click on buy on whatsapp button it sends pre-selected SKU but when i select any other variant it send that previews pre-selected SKU not the current one i have selected. The current_variant.sku data doesn’t change accordingly but shows on product page below product.title correctly.
Also i want some condition on my whatsapp button.
- if the product.type is = “X” then whatsapp button should be visble otherwise not.
- if the current selected variable is not available in inventory the whatsapp button should be hide just like Shopify’s built-in regular add to cart or buy now button does.
* All these conditions should be in real time i.e. doesn’t requires the page reload/refresh.
I am using Debut Theme.
Thanks
I would greatly appreciate your help.
