@softobotics/storefront-cart
v0.1.0
Published
Headless cart: ActiveOrder queries, add/remove/adjust/promotion-code mutations, for storefronts built on @softobotics/storefront-vendure-client.
Keywords
Readme
@softobotics/storefront-cart
Headless cart: ActiveOrder queries and add/remove/adjust/promotion-code mutations, built on
@softobotics/storefront-vendure-client.
Usage
import {addToCart, removeFromCart, adjustQuantity} from '@softobotics/storefront-cart';
const result = await addToCart(variantId, quantity, currencyCode);
if (!result.success) {
// result.error is a Vendure error message, or undefined for a network failure
}Currency is an optional parameter on every mutation here, not something this package resolves itself — that's app-specific (e.g. a cookie), left to the caller.
withCartModificationRetry
Exported, not just an internal helper. Starting checkout moves the order into
ArrangingPayment, which Vendure locks against further cart edits; if the customer navigates
back to the cart, any cart mutation fails with ORDER_MODIFICATION_ERROR. This retries once
after transitioning the order back to AddingItems (an allowed reverse transition) — the
exact retry addToCart also needs, so it's shared rather than duplicated (as it was between
features/cart/routes/actions.ts and features/products/add-to-cart.ts in
vendure-storefront before this extraction).
TransitionOrderToStateMutation
Owned here, not in @softobotics/storefront-checkout, even though checkout also needs it
(to move an order into ArrangingPayment). Checkout imports it back from cart, keeping the
cart↔checkout dependency one-directional despite the real circular import that exists between
features/cart and features/checkout in the source app.
