metatroncubeswdev 365e45406a Bundle Offers Shopify app: discount function, admin, storefront, deploy stack
Rust discount function (one automatic discount evaluating all offers in priority
order, parity with the Odoo engine), React Router admin with Polaris, theme app
extension and app proxy pages, webhooks incl. GDPR, managed-pricing limits, and
a Docker Compose stack (Postgres + Caddy HTTPS) for a single VPS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 21:35:58 -04:00

59 lines
2.4 KiB
Plaintext

{%- 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 -%}
<li>
<a class="bo-box__row" href="/apps/bundles/{{ offer.h }}">
<span class="bo-box__name">{{ name }}</span>
<span class="bo-box__deal">{% render 'bo-summary', offer: offer %}</span>
</a>
</li>
{%- endfor -%}
{%- endcapture -%}
{%- if rows != blank -%}
<aside class="bo-box" aria-labelledby="bo-box-{{ block.id }}" {{ block.shopify_attributes }}>
<h2 class="bo-box__title" id="bo-box-{{ block.id }}">{{ 'bundle_offers.product_box.heading' | t }}</h2>
<ul role="list">{{ rows }}</ul>
</aside>
{%- endif -%}
{% schema %}
{
"name": "Save with a bundle",
"target": "section",
"enabled_on": { "templates": ["product"] },
"settings": []
}
{% endschema %}