Add ticket-to-cart integration
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m6s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m6s
Tickets now appear as cart line items, are included in checkout totals, confirmed on payment, and displayed on the checkout return page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{% macro show_cart(oob=False) %}
|
||||
<div id="cart" {% if oob %} hx-swap-oob="{{oob}}" {% endif%}>
|
||||
{# Empty cart #}
|
||||
{% if not cart and not calendar_cart_entries %}
|
||||
{% if not cart and not calendar_cart_entries and not ticket_cart_entries %}
|
||||
<div class="rounded-2xl border border-dashed border-stone-300 bg-white/80 p-6 sm:p-8 text-center">
|
||||
<div class="inline-flex h-10 w-10 sm:h-12 sm:w-12 items-center justify-center rounded-full bg-stone-100 mb-3">
|
||||
<i class="fa fa-shopping-cart text-stone-500 text-sm sm:text-base" aria-hidden="true"></i>
|
||||
@@ -60,8 +60,41 @@
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if ticket_cart_entries %}
|
||||
<div class="mt-6 border-t border-stone-200 pt-4">
|
||||
<h2 class="text-base font-semibold mb-2">
|
||||
Event tickets
|
||||
</h2>
|
||||
|
||||
<ul class="space-y-2">
|
||||
{% for tk in ticket_cart_entries %}
|
||||
<li class="flex items-start justify-between text-sm">
|
||||
<div>
|
||||
<div class="font-medium">
|
||||
{{ tk.entry_name }}
|
||||
</div>
|
||||
{% if tk.ticket_type_name %}
|
||||
<div class="text-xs text-stone-500">
|
||||
{{ tk.ticket_type_name }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="text-xs text-stone-500">
|
||||
{{ tk.entry_start_at.strftime('%-d %b %Y, %H:%M') }}
|
||||
{% if tk.entry_end_at %}
|
||||
– {{ tk.entry_end_at.strftime('%-d %b %Y, %H:%M') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-4 font-medium">
|
||||
£{{ "%.2f"|format(tk.price or 0) }}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
{{summary(cart, total, calendar_total, calendar_cart_entries,)}}
|
||||
{{summary(cart, total, calendar_total, calendar_cart_entries, ticket_total, ticket_cart_entries)}}
|
||||
|
||||
</div>
|
||||
|
||||
@@ -70,7 +103,7 @@
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro summary(cart, total, calendar_total, calendar_cart_entries, oob=False) %}
|
||||
{% macro summary(cart, total, calendar_total, calendar_cart_entries, ticket_total, ticket_cart_entries, oob=False) %}
|
||||
<aside id="cart-summary" class="lg:pl-2" {% if oob %} hx-swap-oob="{{oob}}" {% endif %}>
|
||||
<div class="rounded-2xl bg-white shadow-sm border border-stone-200 p-4 sm:p-5">
|
||||
<h2 class="text-sm sm:text-base font-semibold text-stone-900 mb-3 sm:mb-4">
|
||||
@@ -87,7 +120,7 @@
|
||||
<div class="flex items-center justify-between">
|
||||
<dt class="text-stone-600">Subtotal</dt>
|
||||
<dd class="text-stone-900">
|
||||
{{ cart_grand_total(cart, total, calendar_total, calendar_cart_entries ) }}
|
||||
{{ cart_grand_total(cart, total, calendar_total, calendar_cart_entries, ticket_total, ticket_cart_entries) }}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
@@ -154,10 +187,11 @@
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro cart_grand_total(cart, total, calendar_total, calendar_cart_entries) %}
|
||||
{% macro cart_grand_total(cart, total, calendar_total, calendar_cart_entries, ticket_total, ticket_cart_entries) %}
|
||||
{% set product_total = total(cart) or 0 %}
|
||||
{% set cal_total = calendar_total(calendar_cart_entries) or 0 %}
|
||||
{% set grand = product_total + cal_total %}
|
||||
{% set tk_total = ticket_total(ticket_cart_entries) or 0 %}
|
||||
{% set grand = product_total + cal_total + tk_total %}
|
||||
|
||||
{% if cart and cart[0].product.regular_price_currency %}
|
||||
{% set symbol = "£" if cart[0].product.regular_price_currency == "GBP" else cart[0].product.regular_price_currency %}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
{# Check if there are any items at all across all groups #}
|
||||
{% set ns = namespace(has_items=false) %}
|
||||
{% for grp in page_groups %}
|
||||
{% if grp.cart_items or grp.calendar_entries %}
|
||||
{% if grp.cart_items or grp.calendar_entries or grp.get('tickets') %}
|
||||
{% set ns.has_items = true %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -30,7 +30,7 @@
|
||||
{% else %}
|
||||
<div class="space-y-4">
|
||||
{% for grp in page_groups %}
|
||||
{% if grp.cart_items or grp.calendar_entries %}
|
||||
{% if grp.cart_items or grp.calendar_entries or grp.get('tickets') %}
|
||||
|
||||
{% if grp.post %}
|
||||
{# Market / page cart card #}
|
||||
@@ -76,6 +76,12 @@
|
||||
{{ grp.calendar_count }} booking{{ 's' if grp.calendar_count != 1 }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if grp.ticket_count is defined and grp.ticket_count > 0 %}
|
||||
<span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-stone-100">
|
||||
<i class="fa fa-ticket" aria-hidden="true"></i>
|
||||
{{ grp.ticket_count }} ticket{{ 's' if grp.ticket_count != 1 }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -115,6 +121,12 @@
|
||||
{{ grp.calendar_count }} booking{{ 's' if grp.calendar_count != 1 }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if grp.ticket_count is defined and grp.ticket_count > 0 %}
|
||||
<span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-amber-100">
|
||||
<i class="fa fa-ticket" aria-hidden="true"></i>
|
||||
{{ grp.ticket_count }} ticket{{ 's' if grp.ticket_count != 1 }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user