web/src/context/CartContext.js
/**
   *
   * @param {*} productData an object with the product object, price object that's being added to the cart
   * @param {*} quantityIncrement should be used when adding a new cart item to a cart
   * @param {*} newQuantity should be used when overriding an existing cart item's quantity
   */
@param {*} productData an object with the product object, price object that's being added to the cart
@param {*} quantityIncrement should be used when adding a new cart item to a cart
@param {*} newQuantity should be used when overriding an existing cart item's quantity
@param { * } productData an object with the product object price object that ' s being added to the cart @param { * } quantityIncrement should be used when adding a new cart item to a cart @param { * } newQuantity should be used when overriding an existing cart item ' s quantity
function addToCart(productData, quantityIncrement = 1, newQuantity = null) {
    const { price, product } = productData
    setCart((prevState) => {
      const cartItem = prevState.products[price.id]
      if (cartItem) {
        return {
          ...prevState,
          products: {
            ...prevState.products,
            [price.id]: {
              ...cartItem,
              quantity: newQuantity || cartItem.quantity + quantityIncrement,
            },
          },
        }
      } else {
        return {
          ...prevState,
          products: {
            ...prevState.products,
            [price.id]: {
              product,
              price,
              quantity: quantityIncrement,
            },
          },
        }
      }
    })
  }
function addToCart ( productData , quantityIncrement = 1 , newQuantity = null ) { const { price , product } = productData setCart ( ( prevState ) => { const cartItem = prevState . products [ price . id ] if ( cartItem ) { return { ... prevState , products : { ... prevState . products , [ price . id ] : { ... cartItem , quantity : newQuantity || cartItem . quantity + quantityIncrement , } , } , } } else { return { ... prevState , products : { ... prevState . products , [ price . id ] : { product , price , quantity : quantityIncrement , } , } , } } } ) }
@param {*} productData an object with the product object, price object that's being added to the cart
 @param {*} quantityIncrement should be used when adding a new cart item to a cart
 @param {*} newQuantity should be used when overriding an existing cart item's quantity
@param { * } productData an object with the product object price object that ' s being added to the cart @param { * } quantityIncrement should be used when adding a new cart item to a cart @param { * } newQuantity should be used when overriding an existing cart item ' s quantity
// products are listed by their price variants id, not the product ids