Skip to main content
Seller-aware variant of Medusa’s updateCartPromotionsWorkflow. Computes promotion actions for the requested codes, then prepares line-item and shipping-method adjustments so each promotion only discounts the owning seller’s items, before creating/removing adjustments and syncing the cart’s applied promotions. Optionally refreshes the payment collection. Triggered by POST /store/carts/:id/promotions.

Usage

import { updateCartSellerPromotionsWorkflow } from "@mercurjs/core/workflows"

await updateCartSellerPromotionsWorkflow(container).run({
  input: {
    cart_id: "cart_123",
    promo_codes: ["SUMMER10"],
    action: "add",
  },
})

Input

cart_id
string
required
The cart to update promotions on.
promo_codes
string[]
Promotion codes to apply; defaults to [].
action
string
One of add, remove, replace; defaults to add.
cart
object
Preloaded cart data; skips the internal cart fetch when provided.
force_refresh_payment_collection
boolean
Refresh the cart’s payment collection after adjustments change.

Result

result
void
No return value; the cart’s adjustments and applied promotions are updated as a side effect.

Hooks

  • validate — runs after the cart is loaded with { input, cart }.
updateCartSellerPromotionsWorkflow.hooks.validate(async ({ input, cart }) => {
  // throw to reject the promotion change
})