getPromotionCodesToApply - Medusa Core Workflows Reference

This documentation provides a reference to the getPromotionCodesToApply. It belongs to the @medusajs/medusa/core-flows package.

This step retrieves the promotion codes to apply on a cart.

Example#

Code
1const data = getPromotionCodesToApply(2  {3    cart: {4      items: [5        {6          adjustments: [{ code: "PROMO10" }]7        }8      ],9      shipping_methods: [10        {11          adjustments: [{ code: "SHIPFREE" }]12        }13      ]14    },15    promo_codes: ["NEWYEAR20"],16    action: PromotionActions.ADD17  },18)

Input#

GetPromotionCodesToApplyStepInputGetPromotionCodesToApplyStepInput
The details of the promotion codes to apply on a cart.
cartobject
The cart containing items and shipping methods.
promo_codesstring[]Optional
the promotion codes to be applied to the cart.
actionADD | REMOVE | REPLACEOptional
Whether to add, remove, or replace promotion codes.

Output#

string[]string[]
stringstring
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