Getting Shipping Methods from Cart

You can use the cart query to retrieve details about a specific cart, including available shipping methods for each bag in the cart.

query RetrieveCart($id: ID!) {
  cart(id: $id) {
    id
    bags {
      id
      availableShippingMethods {
        id
        name
        description
        price {
          amount
          currency
        }
      }
    }
    # Other fields of the Cart type can be queried here
  }
}

Input Parameters for cart

  • id: The ID of the cart you want to retrieve.

Example:

    {
        "id": "cart_ZMe6Bb4GqqUe3BWV"
    }

Apply Shipping Methods to Cart

You can use the cartApplyShippingMethods function to apply specific shipping methods to the bags in your cart. This function takes the desired shipping methods for each bag and updates the cart accordingly.

After applying the shipping methods, the function provides an updated Cart as the result.

mutation ApplyShippingMethods($id: ID!, $input: CartApplyShippingMethodsInput!) {
  cartApplyShippingMethods(id: $id, input: $input) {
    id
    bags {
      id
      selectedShippingMethod {
        id
        name
        description
        price {
          amount
          currency
        }
      }
    }
    # Other fields of the Cart type can be queried here
  }
}

Input Parameters for cartApplyShippingMethods

  • id: The ID of the cart for which you want to apply the shipping methods.
  • bags: An array of objects of type CartApplyShippingMethodInput representing the desired shipping method for each bag.
CartApplyShippingMethodInput
  • bagId: The ID of the bag for which you want to set the shipping method.
  • shippingMethodId: The ID of the desired shipping method for the bag.

Example:

{
  "id": "cart_ZMe6Bb4GqqUe3BWV",
  "input": {
    "bags": [
      {
        "bagId": "bag_ZOX6W0BvVdghMRZP",
        "shippingMethodId": "shippingMethod_12345"
      },
      {
        "bagId": "bag_ZOX6aEBvVdghMRZT",
        "shippingMethodId": "shippingMethod_67890"
      }
    ]
  }
}