Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {% comment %}
- =======================
- PROUCT BUNDLING EXAMPLE
- =======================
- Adding in bundles based on tags
- This section gets the product tags, looks for those with outfit:x where x == the product handle. -->
- Then concatenates them all into one string.
- {% endcomment %}
- {% assign bundle = false %}
- {% assign bundle_handles = "" %} <!-- Stores the handles if they exist -->
- {% capture bundle_handles %}
- {% for t in product.tags %}
- {% if t contains "outfit" %}
- {% assign bundle = true %}
- {% assign bundle_product_array = t | split: ":" %}
- {% assign bundle_product_handle = bundle_product_array.last %}
- {{ bundle_product_handle }}
- {% unless forloop.last %}:{% endunless %}
- {% endif %}
- {% endfor %}
- {% endcapture %}
- {% comment %}Here we actually display the product bundles if they exist {% endcomment %}
- {% if bundle == true %}
- <hr>
- <h3>Shop the look </h3>
- <!--Get the individual products -->
- {% assign product_handles = bundle_handles | split: ":" %}
- {% for p in product_handles %}
- {% assign thehandle = p | strip %}
- {% assign product = all_products[thehandle] %}
- <p>Product Title : {{ product.title }} </p>
- {% if product.available %}
- <p><strong>Product Price :</strong> {{ product.price }} </p>
- <p><strong>Product ID :</strong> {{ product.id }} </p>
- {% else %}
- <p>This product is not available </p>
- {% endif %}
- {% endfor %}
- {% else %}
- <!-- Normal product -->
- {% endif %}
- {% comment %}
- =============================
- End the product bundle snippet
- =============================
- {% endcomment %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement