Cart Actions
- addCouponsToCart
- addProductsToCart
- deleteCouponsFromCart
- deleteProductsFromCart
- fetchCart
- updateProductsInCart
addCouponsToCart
Section titled “addCouponsToCart”Adds coupons to the cart.
import { addCouponsToCart } from '@shopgate/engage/cart';
const couponIds = ['someCouponId', 'anotherCouponId'];
dispatch(addCouponsToCart(couponIds));Parameters
Section titled “Parameters”couponIds(Array<string>): The IDs of the coupons to add to the cart.
addProductsToCart
Section titled “addProductsToCart”Adds products to the cart. For each product that is added, this action determines if the product is a product variant or a base product by the input productId.
Metadata is then updated appropriately based off of the productId.
import { addProductsToCart } from '@shopgate/engage/cart';
const productsData = [ { productId: '1', quantity: 1, }, { productId: '2', quantity: 5, }];
dispatch(addProductsToCart(productsData));Parameters
Section titled “Parameters”data(Array<Object>) required: The data necessary for the products to be added to the cart.productId(string) required: can be a base product ID or variant product ID.quantity(number) required: any number greater than0.options(Array<Object>) Required when a product with options is added to the cart.type(string) required: Option type (selectortext).id(string) required: Option ID.value(string) required: Option value (ID of an option value forselectoptions, input value fortextoptions.)
deleteCouponsFromCart
Section titled “deleteCouponsFromCart”Removes coupons from the cart.
import { deleteCouponsFromCart } from '@shopgate/engage/cart';
const couponIds = ['someCouponId', 'anotherCouponId'];
dispatch(deleteCouponsFromCart(couponIds));Parameters
Section titled “Parameters”couponIds(Array<string>) required: The IDs of the coupons to be removed from the cart.
deleteProductsFromCart
Section titled “deleteProductsFromCart”Removes products from the cart.
import { deleteProductsFromCart } from '@shopgate/engage/cart';
const cartItemIds = ['1', '2', '5'];
dispatch(deleteProductsFromCart(cartItemIds));Parameters
Section titled “Parameters”cartItemIds(Array<string>) required: The IDs of the cart items to be removed from the cart.
fetchCart
Section titled “fetchCart”Retrieves the current cart for the user.
import { fetchCart } from '@shopgate/engage/cart';
dispatch(fetchCart());updateProductsInCart
Section titled “updateProductsInCart”Updates the quantity of a product in the cart. The input can be an array of multiple products.
import { updateProductsInCart } from '@shopgate/engage/cart';
const updateData = [ { cartItemId: '20', quantity: 2, }, { cartItemId: '21', quantity: 4, }]
dispatch(updateProductsInCart(updateData));Parameters
Section titled “Parameters”updateData(Array<Object>) required: The data required to update the products in the cart.cartItemId(string) required: The ID of the cart item to be updated.quantity(number) required: Any number greater than0.

