addShippingMethods - Cart Module Reference

This documentation provides a reference to the addShippingMethods method. This belongs to the Cart Module.

NoteYou should only use this methods when implementing complex customizations. For common cases, check out available workflows instead.

addShippingMethods(data): Promise<CartShippingMethodDTO>#

This method adds a shipping method to carts.

Example#

Code
1const shippingMethod =2  await cartModuleService.addShippingMethods({3    cart_id: "cart_123",4    name: "UPS",5    amount: 3000,6  })

Parameters#

The shipping method to be created and added to the carts. The cart is specified in the cart_id field.

Returns#

PromisePromise<CartShippingMethodDTO>
The added shipping method.

addShippingMethods(data): Promise<CartShippingMethodDTO[]>#

This method adds shipping methods to carts.

Example#

Code
1const shippingMethods =2  await cartModuleService.addShippingMethods([3    {4      cart_id: "cart_123",5      name: "UPS",6      amount: 3000,7    },8    {9      cart_id: "cart_123",10      name: "FedEx",11      amount: 2000,12    },13  ])

Parameters#

The shipping methods to be created and added to the carts. The cart is specified in the cart_id field.

Returns#

PromisePromise<CartShippingMethodDTO[]>
The added shipping methods.

addShippingMethods(cartId, methods, sharedContext?): Promise<CartShippingMethodDTO[]>#

This method adds shipping methods to a cart.

Example#

Code
1const shippingMethods =2  await cartModuleService.addShippingMethods("cart_123", [3    {4      name: "UPS",5      amount: 3000,6    },7    {8      name: "FedEx",9      amount: 2000,10    },11  ])

Parameters#

cartIdstring
The cart's ID.
The shipping methods to be created and added.
sharedContextContextOptional
A context used to share resources, such as transaction manager, between the application and the module.

Returns#

PromisePromise<CartShippingMethodDTO[]>
The added shipping methods.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break