Skip to content

Instantly share code, notes, and snippets.

@martyboggs
Created November 22, 2018 07:56
Show Gist options
  • Save martyboggs/b6c097cf1c92c309522010e95d6b7f35 to your computer and use it in GitHub Desktop.
Save martyboggs/b6c097cf1c92c309522010e95d6b7f35 to your computer and use it in GitHub Desktop.
Shopify Change Colorways into Products
<!-- 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