Create pre-filled shopping carts
Checkout API allows you to create URLs that open a shopping cart and fill it with products and delivery details. Use it for promotions or sharing pre-filled carts with customers. The whole process happens in a JavaScript file and results in a shopping cart URL that you can share with customers or post on social media.
Pre-requirements
Your website must load the following files below the store widget. Both of them are required for the feature to work:
Create a cart-generating URL with JavaScript
You need to create a JSON with cart details, convert it to a string, and then encode it to URI format. The cart structure used in this method matches the one from REST API and cart management methods.
Once you have a variable with cart JSON, use JSON.stringify()
method to convert it to a string, then encode it with the encodeURIComponent()
method.
With the cart encoded to a cartCode
variable, you can compose a link that opens a shopping cart and fills it with products and address details.
Last updated
Was this helpful?