Liquid, JavaScript, themes, sales channels
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 %}
<span>SKU-</span><span class="variant-sku">{{ current_variant.sku }}</span>
The whatsapp button code.
<a href="https://wa.me/91XXXXXXXXXX?text={{ current_variant.sku }}" class="shopify-payment-button__button shopify-payment-button__button--unbranded" style="border-radius:0px; background-color:#25d366">Buy on Whatsapp</a>
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.
1. if the product.type is = "X" then whatsapp button should be visble otherwise not.
2. 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.
Hi @panwar ,
It will need modification in default JS which is responsible for changing the button status and price of product when we change the product variant.
and with the help of liquid code it is possible to add or remove the Whatsapp buy button on product page on the basis of product tag,
Thanks
How to achieve this?
@Anonymous
@panwar
if you are asking about the code then I could not provide you because this will need lots of code modification in JS and time taking task and it is not possible to write a code from outside by watching the store frontend and give you to just paste for the functionality the you had mentioned
Thanks
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024