Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. {% comment %}
  2. =======================
  3. PROUCT BUNDLING EXAMPLE
  4. =======================
  5. Adding in bundles based on tags
  6. This section gets the product tags, looks for those with outfit:x where x == the product handle. -->
  7. Then concatenates them all into one string.
  8. {% endcomment %}
  9.  
  10. {% assign bundle = false %}
  11. {% assign bundle_handles = "" %} <!-- Stores the handles if they exist -->
  12. {% capture bundle_handles %}
  13. {% for t in product.tags %}
  14. {% if t contains "outfit" %}
  15. {% assign bundle = true %}
  16. {% assign bundle_product_array = t | split: ":" %}
  17. {% assign bundle_product_handle = bundle_product_array.last %}
  18. {{ bundle_product_handle }}
  19. {% unless forloop.last %}:{% endunless %}
  20. {% endif %}
  21. {% endfor %}
  22. {% endcapture %}
  23.  
  24. {% comment %}Here we actually display the product bundles if they exist {% endcomment %}
  25. {% if bundle == true %}
  26. <hr>
  27. <h3>Shop the look </h3>
  28. <!--Get the individual products -->
  29. {% assign product_handles = bundle_handles | split: ":" %}
  30. {% for p in product_handles %}
  31. {% assign thehandle = p | strip %}
  32. {% assign product = all_products[thehandle] %}
  33. <p>Product Title : {{ product.title }} </p>
  34. {% if product.available %}
  35. <p><strong>Product Price :</strong> {{ product.price }} </p>
  36. <p><strong>Product ID :</strong> {{ product.id }} </p>
  37. {% else %}
  38. <p>This product is not available </p>
  39. {% endif %}
  40. {% endfor %}
  41. {% else %}
  42. <!-- Normal product -->
  43. {% endif %}
  44.  
  45. {% comment %}
  46. =============================
  47. End the product bundle snippet
  48. =============================
  49. {% endcomment %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement