Created
October 28, 2020 22:38
-
-
Save stevenhoney/0d6c6bd81c0c6fa9553217f2d61a460c to your computer and use it in GitHub Desktop.
Surface shopify product tag for on page JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add this file to /snippets | |
{% assign is_presale_product = false %} | |
{% if product.tags contains 'pre-release' %} | |
{% assign is_presale_product = true %} | |
{% endif %} | |
<script> | |
var is_prerelease_product = "{{is_presale_product | json}}"; | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add this line just before {% render 'product-form'.... | |
{% render 'include-pre-release-check', product: product %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Assuming you have ajax functionality and are using the jQuery wrapper library, or however you are | |
//set up, we want to add this line to into the add to cart js success function somewhere... | |
if(is_prerelease_product){ | |
jQuery.post('/cart/update.js', "attributes[_is_preorder]=true"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment