Alokai

updateShipment

Updates a shipment for a basket.

This method communicates with the updateShipment endpoint of the Vue Storefront API Middleware. In turn, it receives data from the updateShipmentForBasket or the Update shipment for a basket endpoints exposed by SCAPI / OCAPI depending on the middleware configuration.

Signature

export declare function updateShipment(
	props: ShipmentUpdateParams & {
    basketId?: string;
}
): Promise<import("commerce-sdk/dist/checkout/checkout").ShopperBaskets.Basket>;

Parameters

NameRequiredTypeDescription
propsRequiredShipmentUpdateParams & { basketId?: string; }Parameter object which can be used with this method. Refer to its type definition to learn about possible properties.

Returns

Returns a representation of a Basket object.

Referenced Types

  • ShipmentUpdateParams
  • ShopperBaskets.Basket

Examples

Updating a shipment shipping address for a basket by shipmentId and shippingAddress.

import { sdk } from '~/sdk.config.ts';

const basket = await sdk.commerce.updateShipment({
 shipmentId: 'shipmentId',
 shippingAddress: {
   firstName: 'Ward J',
   lastName: 'Adamek',
   address1: '4911  Lincoln Street',
   city: 'IDANHA',
   postalCode: '97350',
   stateCode: 'OR',
   countryCode: 'US'
 }
});

Updating a shipment shipping method for a basket by shipmentId and shippingMethod.

import { sdk } from '~/sdk.config.ts';

const basket = await sdk.commerce.updateShipment({
 shipmentId: 'shipmentId',
 shippingMethod: {
   id: '003'
 }
});

Updating a shipment as a gift for a basket by shipmentId and shippingMethod.

import { sdk } from '~/sdk.config.ts';

const basket = await sdk.commerce.updateShipment({
 shipmentId: 'shipmentId',
 gift: true,
 giftMessage: 'Happy Birthday'
});

On this page