Get the signed-in shopper's cart
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/cart';const options = { method: 'GET', headers: { 'x-storefront-api-key': '<x-storefront-api-key>', Authorization: 'Bearer <token>' }};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://apibase.ecomweb.app/api/v1/stores/example/cart \ --header 'Authorization: Bearer <token>' \ --header 'x-storefront-api-key: <x-storefront-api-key>'Returns the cart of the signed-in shopper with each line priced and the promotions that apply to it. Use these routes when the shopper is signed in, so the cart follows their account across devices; use the guest cart routes for a visitor who is not signed in. The response is 200 with an empty body when the shopper has no cart yet.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The store’s ref, as returned by GET /stores.
Responses
Section titled “Responses”The cart. The body is empty when the shopper has no cart yet.
object
The cart’s lines.
object
The variant’s options. Empty for a line without a variant.
object
The option name, such as Color.
The chosen value, such as Red.
Promotions that apply to the line.
object
Promotion ID.
Promotion name.
Promotion description, when it has one.
How the promotion is triggered, such as automatic or code.
The discount code, for a code promotion.
Kind of promotion.
What the promotion’s condition is based on, such as the product or the order amount.
How the discount is calculated, such as a percentage or a fixed amount.
The discount value; its unit follows discount_method.
The fixed price the line is sold at, for a fixed-price promotion.
Minimum order amount the promotion needs.
Minimum quantity the promotion needs.
When the promotion starts, as an ISO 8601 timestamp.
When the promotion ends, as an ISO 8601 timestamp. Absent when it does not end.
The promotion that gives the best price, when one applies.
object
Promotion ID.
Promotion name.
Promotion description, when it has one.
How the promotion is triggered, such as automatic or code.
The discount code, for a code promotion.
Kind of promotion.
What the promotion’s condition is based on, such as the product or the order amount.
How the discount is calculated, such as a percentage or a fixed amount.
The discount value; its unit follows discount_method.
The fixed price the line is sold at, for a fixed-price promotion.
Minimum order amount the promotion needs.
Minimum quantity the promotion needs.
When the promotion starts, as an ISO 8601 timestamp.
When the promotion ends, as an ISO 8601 timestamp. Absent when it does not end.
The unit price with this promotion applied.
The unit price before the promotion.
The discount this promotion gives on the line.
Cart line ID. Use it to update or remove the line.
ID of the cart the line belongs to.
ID of the product.
ID of the variant, or null when the line has none.
Units in the line.
When the line was added, as an ISO 8601 timestamp.
When the line last changed, as an ISO 8601 timestamp.
Product name. Empty when the product can no longer be read.
URL of the product’s first image. Empty when it has none.
Unit price after promotions. It is 0 when the product’s price cannot be read.
Unit price before promotions.
The variant’s label, such as M - Red. Empty for a line without a variant.
Cart ID.
ID of the signed-in shopper who owns the cart, or null for a guest cart.
The guest session ID that owns the cart, or null once a shopper owns it.
Cart status: ACTIVE, ABANDONED or CONVERTED.
When the cart expires, as an ISO 8601 timestamp, or null when it does not.
When the cart was created, as an ISO 8601 timestamp.
When the cart last changed, as an ISO 8601 timestamp.
Sum of the line totals after promotions.
Sum of the line totals before promotions.
Total discount from promotions.
Shipping fee. It is always 0 here; shipping is priced at checkout.
Amount due: the subtotal after promotions.
Total units across all lines.
Example generated
{ "items": [ { "variant_options": [ { "optionName": "example", "optionValue": "example" } ], "promotions": [ { "id": 1, "name": "example", "description": "example", "mode": "example", "code": "example", "type": "example", "condition_type": "example", "discount_method": "example", "discount_value": 1, "fixed_price": 1, "min_amount": 1, "min_quantity": 1, "start_at": "example", "end_at": "example" } ], "best_promotion": { "id": 1, "name": "example", "description": "example", "mode": "example", "code": "example", "type": "example", "condition_type": "example", "discount_method": "example", "discount_value": 1, "fixed_price": 1, "min_amount": 1, "min_quantity": 1, "start_at": "example", "end_at": "example", "promotion_price": 1, "original_price": 1, "discount_amount": 1 }, "id": "example", "cart_id": "example", "product_id": 1, "variant_id": 1, "quantity": 1, "created_at": "example", "updated_at": "example", "product_name": "example", "product_image": "example", "price": 1, "original_price": 1, "variant_name": "example" } ], "id": "example", "user_id": "example", "session_id": "example", "status": "example", "expires_at": "example", "created_at": "example", "updated_at": "example", "subtotal": 1, "original_subtotal": 1, "discount_amount": 1, "shipping_fee": 1, "total": 1, "item_count": 1}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}