Add or remove products
Add or remove products as needed
Adding products to your cart
You can use the cartAddProducts function to add products to your cart. This function takes the products you want to add and includes them in your cart.
After adding products, the function provides an updated cart Cart as the result.
Here is an example of how you can use the mutation to add products to your cart:
The quantity field indicates the number of products you want to add to the cart. For instance, let’s say your cart already has 1 unit of the product with ID prd_ZJQYAR_-ypwOLKEz
. The following JSON code will add 2 more units of that product, resulting in a total of 3 units:
Updating Line Items in the Cart
To update line items in your cart, you can use the cartLineUpdate mutation. This mutation allows you to modify the quantity of a specific line item in the cart. Here is an example of how to use this mutation:
To update a line item, you’ll need to provide the following parameters:
- $id: The ID of the cart you want to update.
- $lineId: The ID of the specific line item within the cart.
- $quantity: The new quantity you want to set for the line item.
For example, suppose you have a cart with ID “cart_ZWCpKM_dQeQl3oke” and you want to update the quantity of a line item with ID “bagLine_ZWCpLc_dQeQl3okm” to 3 units. You can use the following arguments to the mutation:
Deleting Line Items from the Cart
To remove line items from the cart, you can use the cartLineDelete mutation. This mutation allows you to delete a specific line item from the cart. Here is an example of how to use this mutation:
To delete a line item, you’ll need to provide the following parameters:
- $id: The ID of the cart from which you want to delete the line item.
- $lineId: The ID of the specific line item you wish to remove from the cart.
For example, suppose you have a cart with ID “cart_ZWCpKM_dQeQl3oke” and you want to delete a line item with ID “bagLine_ZWCpLc_dQeQl3okm”. You can use the following arguments to the mutation: