Created
November 22, 2018 07:56
-
-
Save martyboggs/b6c097cf1c92c309522010e95d6b7f35 to your computer and use it in GitHub Desktop.
Shopify Change Colorways into Products
This file contains 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
<!-- theme.liquid - add asset before </body> Make sure the js file exists --> | |
{{ 'bcpo-collection-variants.js' | asset_url | script_tag }} | |
<!-- sections/collection-template.liquid - inside .products --> | |
<script style="display: none"> | |
var bcpo_qv_products = []; | |
</script> | |
<!-- snippets/product-grid-item.liquid - add class to .box.product --> | |
id-{{ product.id }} | |
<!-- snippets/product-grid-item.liquid - add code inside .box.product --> | |
{% if product.metafields.bcpo.bcpo_data %} | |
<script style="display: none"> | |
var bcpo_qv_product = {{ product | json }}; | |
var bcpo_qv_data = {{ product.metafields.bcpo.bcpo_data }}; | |
var num = bcpo_qv_product.options.indexOf('Color'); | |
if (num !== -1) { | |
bcpo_qv_products.push({product: bcpo_qv_product, data: bcpo_qv_data, num: num}); | |
bcpo_qv_products[bcpo_qv_products.length - 1].product.url = '{{ product.url }}'; | |
} | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment