{%- comment -%} F16: "Save with a bundle" on product pages: up to 3 running offers (Product pages on) that contain this product, as a fixed-bundle line, or a product / variant / collection in any scope. {%- endcomment -%} {%- liquid assign data = app.metafields.bundle_offers.storefront.value assign country = localization.country.iso_code assign pid = product.id | append: '' assign vids = product.variants | map: 'id' | join: ',' | split: ',' assign cids = product.collections | map: 'id' | join: ',' | split: ',' assign locale = request.locale.iso_code -%} {%- capture rows -%} {%- assign n = 0 -%} {%- for offer in data.offers -%} {%- if n >= 3 -%}{%- break -%}{%- endif -%} {%- if offer.f[1] != 1 -%}{%- continue -%}{%- endif -%} {%- if offer.cc.size > 0 -%}{%- unless offer.cc contains country -%}{%- continue -%}{%- endunless -%}{%- endif -%} {%- assign hit = false -%} {%- for line in offer.l -%} {%- if line.p == pid -%}{%- assign hit = true -%}{%- endif -%} {%- endfor -%} {%- assign keys = 'sc,bs,gs' | split: ',' -%} {%- for key in keys -%} {%- assign s = offer[key] -%} {%- if s -%} {%- if s.p contains pid -%}{%- assign hit = true -%}{%- endif -%} {%- for v in vids -%}{%- if s.v contains v -%}{%- assign hit = true -%}{%- endif -%}{%- endfor -%} {%- for c in cids -%}{%- if s.c contains c -%}{%- assign hit = true -%}{%- endif -%}{%- endfor -%} {%- endif -%} {%- endfor -%} {%- unless hit -%}{%- continue -%}{%- endunless -%} {%- assign n = n | plus: 1 -%} {%- assign name = offer.n -%} {%- if offer.i[locale].n != blank -%}{%- assign name = offer.i[locale].n -%}{%- endif -%}