Fix cross-origin cart +/- buttons by supporting cart_quantity_url in template
The cart_item macro now checks for cart_quantity_url (defined only in the cart app) and uses it for same-origin quantity updates, falling back to market_product_url. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -188,10 +188,11 @@
|
||||
<div class="mt-3 flex flex-col sm:flex-row sm:items-center justify-between gap-2 sm:gap-4">
|
||||
<div class="flex items-center gap-2 text-xs sm:text-sm text-stone-700">
|
||||
<span class="text-[0.65rem] sm:text-xs uppercase tracking-wide text-stone-500">Quantity</span>
|
||||
{% set qty_url = cart_quantity_url(item.product_id) if cart_quantity_url is defined else market_product_url(p.slug, 'cart', item.market_place) %}
|
||||
<form
|
||||
action="{{ market_product_url(p.slug, 'cart', item.market_place) }}"
|
||||
action="{{ qty_url }}"
|
||||
method="post"
|
||||
hx-post="{{ market_product_url(p.slug, 'cart', item.market_place) }}"
|
||||
hx-post="{{ qty_url }}"
|
||||
hx-target="#cart-mini"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
@@ -212,9 +213,9 @@
|
||||
{{ item.quantity }}
|
||||
</span>
|
||||
<form
|
||||
action="{{ market_product_url(p.slug, 'cart', item.market_place) }}"
|
||||
action="{{ qty_url }}"
|
||||
method="post"
|
||||
hx-post="{{ market_product_url(p.slug, 'cart', item.market_place) }}"
|
||||
hx-post="{{ qty_url }}"
|
||||
hx-target="#cart-mini"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user