store: cart with WhatsApp checkout #38
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add a
localStoragecart that checks out through a single WhatsApp deep link — no payment gateway, no accounts, no server, no new dependencies.lib/cart.tsexposes auseCarthook (lines,add,setQty,remove,clear,total,hasUnpricedLine) over storage keyapja-cart-v1, reading on mount insideuseEffectso a static export cannot hydration-mismatch, syncing across components via a module-level listener set plus astoragelistener, and discarding malformed stored values as an empty cart. Add a headerCartButtonwith a count badge, and an add-to-cart control with a quantity stepper and a fulfilment choice between shipping and installing at the Situbondo workshop — each option shown only when actually possible, as static text when only one is, and replaced by a "tanyakan ketersediaan" WhatsApp link when out of stock./carthandles the empty cart, unpriced lines, a mix of shippable and pickup-only lines, and a required destination gating checkout.lib/checkout-message.tsis a pure tested function producing the WhatsApp text, capping at 15 itemised lines plusdan N barang lainnyabecausewa.metruncates long messages unpredictably. Checkout does not clear the cart; an explicit "Kosongkan keranjang" button does.Acceptance:
pnpm --filter garage-store testpasses; adding two items, choosing install on one, and pressing checkout opens awa.meURL whose decoded text matches the specified format.