Skip to content

Instantly share code, notes, and snippets.

@stevenhoney
Created October 28, 2020 22:38
Show Gist options
  • Save stevenhoney/0d6c6bd81c0c6fa9553217f2d61a460c to your computer and use it in GitHub Desktop.
Save stevenhoney/0d6c6bd81c0c6fa9553217f2d61a460c to your computer and use it in GitHub Desktop.
Surface shopify product tag for on page JS
//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>
//Add this line just before {% render 'product-form'....
{% render 'include-pre-release-check', product: product %}
//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