This article presents possible use cases and corresponding sample flows that you can support. It provides a useful starting point as you plan your implementation.
A custom storefront or POS system needs to create carts and add products for customers. This is the foundational flow for any e-commerce integration.
To create a cart with products:
Call Create Cart with initial catalog items:
Save the returned cart.id for future operations on this cart.
To add more items later, call Add Line Items with the saved cart ID:
The response includes the updated cart with all line items and their current prices.
Customers often have discount coupons they want to apply before checkout. This flow shows how to apply a coupon and display updated pricing.
To apply a coupon and calculate totals:
Call Add Coupon with the coupon code:
If the coupon is valid, it's added to the cart. If invalid, you'll receive an error with details.
Call Calculate Cart to get the detailed pricing breakdown:
The response includes:
summary.priceSummary: Subtotal, discount amount, delivery cost, tax, and totalsummary.discounts: Applied discounts including the couponsummary.priceVerificationToken: Save this token for checkoutsummary.violations: Any business rule violationsDisplay the pricing summary to the customer, showing original price, discount, and final total.
When a customer is ready to buy, the cart needs to be validated, calculated, and placed as an order. This flow covers the full checkout sequence.
To complete the checkout process:
Ensure the cart has all required information:
Call Update Cart to set customer information if not already set:
Call Set Delivery Method to select shipping:
Call Calculate Cart to get the full pricing breakdown, including delivery, taxes, fees, and gift cards:
Check for violations in summary.violations. If any exist, display them to the customer and don't proceed.
Save the summary.priceVerificationToken from the calculation response.
Display the final pricing to the customer for confirmation.
Call Place Order to complete checkout:
The response includes:
orderId: The created order IDcompleted: Whether the order was created and payment completedpaymentGatewayOrderId: Payment gateway order ID, returned when money needs to be charged. Pass it as the paymentId parameter to the Wix Pay startPayment() function to collect payment. This requires Velo; if your app can't run Velo code, send the customer to the Wix-hosted checkout page with Get Checkout URL instead.If completed is true, redirect the customer to your order confirmation page. Otherwise, handle the pending payment state.
For standard e-commerce shopping flows, the Current Cart service lets you manage the customer's cart without tracking cart IDs. The cart is automatically associated with the customer's session.
To build a session-based shopping experience:
Call Add Line Items To Current Cart when a customer clicks "Add to Cart":
Note: If no current cart exists, this method automatically creates one. If a current cart already exists, items are added to it.
Call Get Current Cart to display the cart:
This retrieves the customer's current cart without needing a cart ID. The cart is automatically associated with the customer's session (visitor ID or member ID).
To update quantities, call Update Line Items In Current Cart:
To remove items, call Remove Line Items From Current Cart:
For checkout, call Calculate Current Cart to get pricing, then retrieve the cart ID from the response and call Place Order with that cart ID.
Products can become unavailable or have reduced stock while they're in a customer's cart. This flow shows how to detect and handle inventory changes.
To handle out-of-stock items:
Call Refresh Cart to sync with current inventory:
Check each line item's status in the response:
IN_STOCK: Full requested quantity is availablePARTIALLY_IN_STOCK: Some quantity is available (check quantityInfo.confirmedQuantity)OUT_OF_STOCK: No stock available (confirmedQuantity is 0)REMOVED_FROM_CATALOG: Product no longer existsFor partially available items, compare confirmedQuantity to requestedQuantity:
For out-of-stock items, either:
confirmedQuantity: 0 (customer can see what's unavailable)When items are restocked, confirmedQuantity doesn't automatically increase. To allow customers to purchase more after restocking:
availableQuantity.availableQuantity now exceeds confirmedQuantity.Customers may have gift cards they want to apply toward their purchase. This flow shows how to add a gift card and check the remaining balance due.
To add a gift card as payment:
Call Add Gift Card with the gift card code:
The API validates the gift card and adds it to paymentInfo.giftCards if valid.
Call Calculate Cart to get the full pricing breakdown including gift card deductions:
Note: Calculate Cart always includes gift cards in the calculation. To selectively include or exclude components like gift cards, use Estimate Cart instead.
Check the payment summary in the response:
paymentSummary.totalAfterGiftCards: Amount due after applying gift card balancepaymentSummary.giftCards[0].amount: Amount deducted from gift cardpaymentSummary.requiresPaymentAfterGiftCard: Whether additional payment is neededIf the gift card fully covers the cart total, totalAfterGiftCards will be 0 and no additional payment is required.
During Place Order, the gift card balance is automatically applied before charging the payment method.
Cart abandonment is common in e-commerce. This flow shows how to detect abandoned carts and bring customers back to complete their purchase.
To build a cart recovery flow:
Set up a webhook or scheduled job to detect abandoned carts (carts not checked out after a certain time).
Call Get Cart to retrieve the cart details:
Check if the cart is still valid:
orderPlaced should be false (not yet checked out).Send a recovery email to the customer using cart.customerInfo.email with:
When the customer clicks the link, call Get Cart again to load their cart. The API automatically refreshes it with current prices and inventory.
If items are no longer available, use the flow in "Handle out-of-stock items" above to notify the customer.
Guide the customer through the checkout process using the flow in "Complete the checkout process" above.
Last updated: 5 August 2026