Edit Shopify Theme
- Go to the Shopify theme
- Find the file of a product page
- Add the code to collect the number
<input
class=""
type="text"
id="phone-number"
name="phone-number"
placeholder="Phone number"
>
<button
type="button"
id="whatsapp-button"
style="display:block;width:100%;font-size:16px;font-weight:700;margin-top:10px;line-height:21px;"
class="bttn"
disabled
>
Notify me on WhatsApp
</button>
4. Then add the code that passes this information to Simio
<!-- SIMIO BACK IN STOCK -->
<script>
const phoneNumberInput = document.getElementById('phone-number');
const whatsappButton = document.getElementById('whatsapp-button');
function handleWhatsAppAlert() {
whatsappButton.disabled = true;
whatsappButton.textContent = 'Subscription in progress...';
const phoneNumber = phoneNumberInput.value.trim();
const customerId = "{{ask support}}";
if (phoneNumber.length > 8) {
whatsappButton.disabled = true;
whatsappButton.textContent = 'Subscription in progress...';
fetch('https://app.getsimio.com/backinstock/subscribe', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
phoneNumber: phoneNumber,
customerId: customerId,
variantId: {{ product.selected_or_first_available_variant.id }},
})
})
.then(response => {
if (response.ok) {
return response.text();
}
throw new Error('Error during query.');
})
.then(data => {
whatsappButton.textContent = "Understood, we will notify you as soon as it is back in stock!";
})
.catch(error => {
console.error(error);
whatsappButton.textContent = "An error occurred";
});
}
}
phoneNumberInput.addEventListener('input', function() {
if (phoneNumberInput.value.trim().length > 8) {
whatsappButton.textContent = "Notify me on WhatsApp";
whatsappButton.removeAttribute('disabled');
} else {
whatsappButton.setAttribute('disabled', 'true');
}
});
whatsappButton.addEventListener('click', handleWhatsAppAlert);
</script>
<!-- --------- -->
5. Adjust the style to your site