addShippingMethodAdjustments - Cart Module Reference

This documentation provides a reference to the addShippingMethodAdjustments 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.

addShippingMethodAdjustments(data): Promise<ShippingMethodAdjustmentDTO[]>#

This method adds shipping method adjustments to shipping methods.

Example#

Code
1const shippingMethodAdjustments =2  await cartModuleService.addShippingMethodAdjustments([3    {4      shipping_method_id: "casm_123",5      code: "FREESHIPPING",6      amount: 3000,7    },8    {9      shipping_method_id: "casm_321",10      code: "10%OFF",11      amount: 1500,12    },13  ])

Parameters#

The shipping method adjustments to be created and added to shipping methods. The shipping method is specified by the shipping_method_id field.

Returns#

PromisePromise<ShippingMethodAdjustmentDTO[]>
The added shipping method adjustments.

addShippingMethodAdjustments(data): Promise<ShippingMethodAdjustmentDTO>#

This method adds a shipping method adjustment to a shipping method.

Example#

Code
1const shippingMethodAdjustment =2  await cartModuleService.addShippingMethodAdjustments({3    shipping_method_id: "casm_123",4    code: "FREESHIPPING",5    amount: 3000,6  })

Parameters#

The shipping method adjustment to be created and added to a shipping method. The shipping method is specified by the shipping_method_id field.

Returns#

The added shipping method adjustment.

addShippingMethodAdjustments(cartId, data, sharedContext?): Promise<ShippingMethodAdjustmentDTO[]>#

This method adds shipping method adjustments to shipping methods in a cart.

Example#

Code
1const shippingMethodAdjustments =2  await cartModuleService.addShippingMethodAdjustments(3    "cart_123",4    [5      {6        shipping_method_id: "casm_123",7        code: "FREESHIPPING",8        amount: 3000,9      },10      {11        shipping_method_id: "casm_321",12        code: "10%OFF",13        amount: 1500,14      },15    ]16  )

Parameters#

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

Returns#

PromisePromise<ShippingMethodAdjustmentDTO[]>
The added shipping method adjustments.
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