Cart Mutations
This section documents the GraphQL mutations available for managing shopping carts in the YSCP platform. Cart mutations allow you to create carts, add products, apply coupons, and perform other cart-related operations.
Available Mutations
The following cart mutations are available:
- AddProductsToCartMutation - Adds one or more products to the cart
- ApplyCouponToCartMutation - Applies a coupon code to the cart
- ApplyGiftCardToCartMutation - Applies a gift card to the cart
- ClearCartMutation - Removes all items from the cart
- ConvertCartMutation - Converts a guest cart to a customer cart
- CreateCustomerCartMutation - Creates a new cart for a customer
- CreateGuestCartMutation - Creates a new cart for a guest
- RemoveCouponFromCartMutation - Removes a coupon from the cart
- RemoveGiftCardFromCartMutation - Removes a gift card from the cart
- RemoveItemFromCartMutation - Removes an item from the cart
- UpdateCartItemsMutation - Updates items in the cart
Common Parameters
Most cart mutations require the following parameters:
cartId: The unique identifier of the cart to operate onsiteId: (Optional) The site ID where the cart is created
Authentication
Cart mutations can be performed by both authenticated users and guest users. For guest users, a cart ID must be obtained from the createGuestCart mutation before other cart operations can be performed.
Error Handling
Cart mutations may return errors in the following cases:
- Invalid cart ID
- Product not found
- Insufficient stock
- Invalid coupon code
- Coupon usage limit exceeded
- Coupon expired
Each error includes a message explaining the issue and how to resolve it.