Newer Version Available

This content describes an older version of this product. View Latest

Commerce Webstore Cart, Preserve

Preserve cart contents when a guest logs in as an authenticated customer.

To use this API, pass the guest session cookies in the request as part of the authenticated user session. For more information, see Set Up Guest Checkout for Headless Commerce Stores.

When a guest adds products to their cart and logs into a store, this API creates a new authorized cart and transfers the contents and coupons of the guest cart to the authorized cart. The API doesn’t transfer delivery or tax calculation details, or custom fields.

After the guest cart contents are successfully preserved, the guest cart is deleted. If the customer previously added items to their cart while logged in, the new authorized cart becomes the primary cart, and the previous cart becomes a secondary cart.

If the Preserve Guest Carts feature is turned off, if the guest cart is empty, or if the guest cart belongs to a different browser than the one the customer uses to log in, the API results in no operation and returns an empty response. Preserve Guest Carts is enabled by default in stores created after the Spring '24 release.

Resource
1/commerce/webstores/webstoreId/carts/cartStateOrId/actions/preserve
Available version
60.0
HTTP methods
POST
Request parameters for POST
Parameter Name Type Description Required or Optional Available Version
currencyIsoCode String The currency ISO code of the cart. Optional 60.0
effectiveAccountId String ID of the buyer account or guest buyer profile for which the request is made. If null, the default value is determined from context. Optional 60.0
Response body for POST
Preserve Cart Output