Skip to main content
The Offer module ships eight workflows: five for offers and their prices and stock, and three for offer conditions. Import them from @mercurjs/core/workflows and run them with the Medusa container.

createOffersWorkflow

Creates offers with their inventory items, prices, and links. Returns the created OfferDTO[]. Each CreateOfferDTO requires seller_id, created_by, sku, variant_id, shipping_profile_id, prices, and at least one inventory_items entry. Optional fields are ean, upc, manage_inventory, allow_backorder, leadtime_to_ship, condition_id, and metadata. An inventory_items entry takes required_quantity (default 1), sku, title, and stock_levels (location_id, stocked_quantity). A price takes amount, currency_code, and optional min_quantity, max_quantity, and rules. The run creates the inventory items and links them to the offer and to the store of the first entry. It adds prices to each variant’s price set with an offer_id rule, creating the price set first if the variant has none. It also links each master product to its first offer’s shipping profile when the product has no profile.

updateOffersWorkflow

Updates offer rows and, for entries with a prices array, replaces that offer’s prices through upsertOfferPricesWorkflow. Returns the updated OfferDTO[]. UpdateOfferDTO accepts sku, shipping_profile_id, manage_inventory, allow_backorder, leadtime_to_ship, condition_id, metadata, and prices. Leave out prices to keep the current rows. A condition_id must point at an active condition. previous_offers holds the offer rows as they were before the write.

upsertOfferPricesWorkflow

Replaces each listed offer’s prices without touching other offers on the same variant. Returns { offer_id, price_ids }[] for the prices it created. A price with an id updates that row, a price without one is added, and owned prices left out are deleted with their links. An id that belongs to another offer fails the run with Price … does not belong to offer …. Each entry in offers has these fields:
  • offer_id: the offer
  • previous_prices: the offer’s prices before the write
  • prices: the offer’s prices after the write
  • created: ids of new prices
  • updated: ids whose amount, currency, quantity bounds, or rules changed; an unchanged row resent with its id isn’t listed
  • deleted: ids of removed prices
The hook also fires when updateOffersWorkflow runs the upsert, so one handler covers both entry points:
src/workflows/hooks/offer-prices-upserted.ts
Deleted prices are gone for good, so this payload is the only place to read their old values.

deleteOffersWorkflow

Soft-deletes offers. It has no step that removes their prices or inventory items. offers is a snapshot taken before the delete, with each offer’s prices.

batchOfferInventoryItemsWorkflow

Creates, updates, and removes offer ↔ inventory_item links on one offer. Returns { created, updated, deleted }. The run fails when the offer doesn’t exist, an item in create doesn’t exist, an item in delete isn’t linked, or an id repeats within or across the lists.

createOfferConditionsWorkflow

Creates offer conditions. Returns OfferConditionDTO[].

updateOfferConditionsWorkflow

Updates offer conditions by id. Returns OfferConditionDTO[].

deleteOfferConditionsWorkflow

Soft-deletes offer conditions. The run fails when an id doesn’t exist or when any offer still uses one of the conditions.