- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Menu
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Retrieve Cart in Storefront
You can retrieve a cart by sending a request to the Get a Cart API route.
Assuming you stored the cart's ID in the localStorage
as explained in the Create Cart guide, pass that ID as a path parameter to the request.
For example:
The response of the Retrieve Cart API route has a cart
field, which is a cart object.
Format Prices#
When displaying the cart's totals or line item's price, make sure to format the price as implemented in the formatPrice
function shown in the above snippet:
Since this is the same function used to format the prices of products, you can define the function in one place and re-use it where necessary. In that case, make sure to pass the currency code as a parameter.
Was this page helpful?