Skip to main content
Applies partial updates to offer rows (sku, shipping_profile_id, metadata). When an entry sets prices, the offer’s price ladder is rewritten with replace semantics: rows with id are updated in place, rows without id are added, and existing offer-owned prices omitted from the array are removed — all on the variant’s shared PriceSet, scoped by the offer_id price rule. Price ownership is asserted so an offer can’t touch another offer’s rows. Emits offer.updated. Triggered by POST /vendor/offers/:id and the offer batch routes.

Usage

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

const { result } = await updateOffersWorkflow(container).run({
  input: {
    offers: [
      {
        id: "offer_123",
        prices: [{ amount: 1799, currency_code: "usd" }],
      },
    ],
  },
})

Input

offers
object[]
required
Offer updates, keyed by ID.
additional_data
object
Custom data passed through to the workflow hooks.

Result

result
OfferDTO[]
The updated offers.

Hooks

  • validate — runs first with { input }.
  • offersUpdated — runs after the update with { offers, additional_data }.
updateOffersWorkflow.hooks.offersUpdated(async ({ offers, additional_data }) => {
  // react to updated offers
})