Skip to main content

Cart

An object with all the items added to the cart by a potential buyer. The frontend can interact with our GRAPHQL to add, update or remove items.

info

The cart is intended to handle only product interacions (addition, removal or update of quantity). Payment methods and shipping are handled on the checkout.

Create cart

You can initiate the cart even before adding products to it, so you decide when it's more convenient for you to do it. You need to provide us though with the reference to the customer's session id that is created by you in the frontend.

Retrieve an array of the products added to your channel.

Cart object

PropertyTypeDescription
customer_session_idStringUnique identifier for the customer's session.
shippingCountryStringInformation about the shipping country (or null if not set).
currencyStringCurrency code (e.g., "NOK").


info

Heads up! A cart requirement will be to add a shipping country to it (the country the products are going to be shipped to). Once a product is added to the cart, the paramenter available_shipping_countries will automatically get the shipping countries from the supplier's avaibale shipping countries and return an array with the shipping codes.

You may want to interact with a created cart line items in the following ways:

  • add an additional item o multiple items to the cart object
  • update the quantity of an added item
  • remove an item or multiple items from the cart object

Add an item

From the GRAPHQL product operations, you get all necessary information to complete the line_items object and add an item to the cart.

info

It is possible to add more than one item on this mutation, just add additional objects to the line_items array.



info

Note that since you have added a product to the cart, the parameter available_shipping_countries is updated. This information is usefull when updating the cart shipping country, and once you do it, the available_shippings inside each line item will return an array with all the shipping options for that product.

You should also pay attention to the shipping parameter inside each line item. This is null now, but when you assign a shipping to the product, this parameter will return an object with the assigned shipping data.

Update cart shipping country

Once you have created the cart, you can update the shipping country. If you know that you will be working just with one specific country, feel free to update it even before adding a product to the cart.

If you will be working with products that have different shipping countries, you can get the info of the cart available shipping countries directly from the cart object paramenter: available_shipping_countries



Now that you have added a shipping country to the cart, you may see that the line items come with the product available shippings just for that country. This allows you to easily select the shipping id to assign to each product.

Update an item's shipping class or quantity

At any point before initiating the payment you can update the quantity of a line item or the shipping class assigned to it.

It is mandatory to assign a shipping class to a product, a payment cannot be initiated if the shipping class of a line item is null. You can easily do it if the cart has a shipping country as you have the the shipping ids information on the product_available_shippings parameter available in the cart items of the cart.



Remove an item



As response you will get the updated cart. If there was only one product on the cart, the line_items parameter will return an empty array.

Get cart information

At any time you can retrieve cart information with all the added items.



Delete cart

In case you need to delete a cart, it is also possible via the GRAPHQL.