StoreOSv0.24.0
Guides

StoreOS checkout guide

How checkout works — cart, discounts, delivery, and placing an order with StoreOS.

What checkout is

Checkout is when a customer turns their cart into a real order on StoreOS. Your app owns the cart UI and checkout form; StoreOS validates inventory, applies discounts (codes and automatic offers), calculates delivery, and creates the invoice.

Cart (your app)  →  previewDiscounts (optional)  →  createOrder  →  Order on StoreOS

Who does what

StepYour appStoreOS API
Cart itemsTrack productId, variantId, qty—
Offer badges"Buy 1 Get 1", free-shipping baractiveOffers
Shipping formCollect address, delivery area—
Delivery feeDisplay totalgetTenant() → charges
Discounts + code fieldSummary rows, apply buttonpreviewDiscounts
Place order buttonSubmitcreateOrder
Confirmation pageShow invoiceUIDReturns order object

Flow

  1. Shipping address — caption, latitude, longitude (location reference)
  2. Delivery area — e.g. DHAKA or OUTSIDE_CAPITAL (affects fee)
  3. Delivery charge — read from tenant.charges via getTenant()
  4. Discounts (optional) — previewDiscounts with line items, delivery area, and the code the customer typed
  5. Payment method — COD (cash on delivery) or ONLINE
  6. createOrder — submits everything to StoreOS
  7. Redirect — /order-confirmation/[invoiceUID]

Discounts

Merchants create discounts in the console under Discounts. There are four types, each either a code the customer types or automatic:

TypeExample
Amount off products20% off the Summer collection
Amount off order৳200 off orders over ৳2,000
Buy X get YBuy 1 shirt, get 1 free
Free shippingFree delivery in Dhaka over ৳1,500

createOrder always applies eligible automatic discounts and the couponCode you send. Call previewDiscounts with the same input to show the breakdown before the customer places the order. Its hints tell the customer what's missing ("Add 1 more item to get 1 free"), and codeError explains why a code didn't apply.


Cart

Save the shopper cart with upsertCart, or use useCart from the React SDK. Pass the same cartId to createOrder so the cart is marked converted.

// Example cart line — display fields plus the ids checkout needs
{
  productId: "…",
  variantId: "…",
  quantity: 2,
  product: { name: "Linen shirt", unitPrice: 1200 },
}

SDK example

import { store } from "@/lib/store";

// 1. Load delivery rules
const tenant = await store.getTenant();

// 2. Preview discounts (automatic offers + optional code)
const preview = await store.previewDiscounts({
  lineItems: cartItems,
  code: "SAVE10",
  deliveryArea: "DHAKA",
});

// 3. Place order — StoreOS applies the same discounts
const { order, authToken } = await store.createOrder({
  lineItems: cartItems,
  shippingAddress: {
    caption: "House 12, Road 5, Dhaka",
    latitude: 23.8103,
    longitude: 90.4125,
  },
  paymentMethod: "COD",
  deliveryArea: "DHAKA",
  // Required when the region lists sub-areas in tenant.charges.deliveryRegions
  deliverySubArea: "Mirpur",
  couponCode: preview.code,
  cartId,
});

// 4. Redirect — order.invoiceUID is the public order ID
router.push(`/order-confirmation/${order.invoiceUID}`);

Guest vs logged-in

CustomerWhat to do
GuestCall createOrder without a token; pass name/phone in order input if required
Logged instore.setAccessToken() before checkout — order links to their account
Guest after orderAPI may return authToken — SDK saves it for getOrder() tracking

Payment methods

ValueMeaning
CODCash on delivery — no payment gateway needed
ONLINEOnline payment — your app integrates the payment provider

More reference

On this page