github medusajs/medusa v2.12.0
2.12.0: New Promotion limit, custom display ID on orders, improved event management

5 hours ago

Highlights

This release introduces migrations, so remember to run migrations after installing the version:

npx medusa db:migrate

In addition to migrations with schema changes, this release also runs a data migration script added in this PR. The script populates a new version column on order line item adjustments, setting it to the latest version of the associated order.

Custom order display ID

This release introduces a custom_display_id field on orders, along with a hook for automatically generating the value at order creation.

The key changes are:

  • New custom_display_id column on orders
  • Order Module now accepts a generateCustomDisplayId function in its module options

The generation can be used like so:

// medusa-config.ts
defineConfig({
  // ...
  modules: [{
    resolve: "@medusajs/medusa/order",
    options: {
      generateCustomDisplayId: async function (order: OrderTypes.CreateOrderDTO, sharedContext: Context) {
        // Return your custom display id
      }
    }
  }]
})

We intentionally kept the existing display_id column unchanged. Migrating it from an auto-incrementing integer to text would be a significant breaking change.

To show the new custom_display_id in the Admin dashboard, you can use the View Configurations feature to customize columns on the order table:

// medusa-config.ts
defineConfig({
  // ...
  featureFlags: {
    view_configurations: true
  }
})

Promotion limit

This release expands promotion configuration capabilities by introducing a limit enforced on promotions. Previously, limits could only be enforced at the campaign level. You can now configure limits at three levels:

  • Campaign-level: limit the number of times a certain promotion in a campaign can be used
  • Campaign-level per customer/email: limit the number of times a certain promotion in a campaign can be used by a specific customer or email
  • Promotion-level: limit the number of times a certain promotion can be used

Promotions on exchanges

This release adds the option to carry over promotions to exchanges on orders. When creating an exchange, you often want the original promotions applied to the outbound items to avoid recharging the customer. You can now opt into this by enabling "Carry over promotions" during the exchange flow.

Admin user deletion

This release adds the ability for admin users to delete other users. This is a temporary solution ahead of a proper permissions system, which we plan to work on in the near future.

Limiting event emission

This release improves event management, reducing unnecessary memory and processing overhead by only emitting events and adding to event queues whenever there are subscribers to the events.

Shipping Option Type relation

Breaking change

The relationship between Shipping Options and Shipping Option Types has changed from one-to-one to many-to-one. This change should be deemed more a fix, than an actual change of the feature, as this was always the intention. However, it is a breaking change, since the property name has changed.

Features

Bugs

  • fix(dashboard): fix import for ptPT locale by @willbouch in #13986
  • fix(dashboard): Limit file uploads to 1MB by @juanzgc in #13981
  • fix(core-flows,types): change doc for upload file functions by @willbouch in #13809
  • fix(): Lock process payment to prevent ingesting payment processing t… by @adrien2p in #13977
  • fix(dashboard): update orders page filters to match interface expected by old DataTable component by @NicolasGorga in #13994
  • fix(product, types): add missing types for variant images and thumbnails by @shahednasser in #14026
  • fix(dashboard): use order version 1 for the initial node of activity timeline by @NicolasGorga in #13997
  • fix(medusa): preprocess version as number in AdminGetOrdersOrderParams validator by @NicolasGorga in #13996
  • fix(): Proper schema usage when running migrations by @adrien2p in #14036
  • fix(draft-order): Update copy phone number by @juanzgc in #14044
  • fix(): Identify step that should require a save on checkpoint by @adrien2p in #14037
  • fix(dashboard): reference global vite bin from scripts by @fPolic in #14049
  • fix(core-flows): avoid overriding customer and region from setPricingContext hook result by @NicolasGorga in #14022
  • fix(payment): Double idempotent capture called with auto capture beha… by @adrien2p in #14073
  • chore(): Update glob package by @adrien2p in #14083
  • fix(medusa): avoid throwing on error on set step failure endpoint by @NicolasGorga in #14066
  • fix(core-flows): prevent completing cart from webhook when order already exists by @NicolasGorga in #14108
  • fix(core-flows): Add discountable properties in queried fields to avoid overriding discountable properties when set by @NicolasGorga in #14105
  • fix(): Workflow engine redis worker instance in worker mode by @adrien2p in #14099
  • fix(product): add missing decorators to updateProductOptionValues method by @shahednasser in #14060
  • fix: Compute "virtual" adjustments for order previews by @olivermrbl in #13306
  • fix(core-flows): lock mark as delivered fulfillment/order flows by @NicolasGorga in #14111
  • fix(orchestration): fetch fields from link entities by @carlos-r-l-rodrigues in #14097
  • fix(js-sdk,types,medusa): add HTTP types for update order change API route by @shahednasser in #14169
  • fix(core-flows): create reservations on draft order conversion to regular order by @NicolasGorga in #14010
  • fix(fulfillment): make relationship between SO and SO type M:1 by @fPolic in #14061
  • fix(product): Update performance issue by @adrien2p in #14150

Documentation

Chores

  • chore(docs): Update version in documentation (automated) by @github-actions[bot] in #13966
  • chore(docs): Generated DML JSON files (automated) by @github-actions[bot] in #13967
  • chore(docs): Generated References (automated) by @github-actions[bot] in #13969
  • chore(medusa): fix query http type parameter for get claim route by @shahednasser in #13974
  • chore: cleanup/improve bootstrap by @adrien2p in #14023
  • chore: Configure auth on JS-SDK in dashboard by @olivermrbl in #14013
  • chore(): Remove lodash.set entirely by @adrien2p in #14041
  • chore(): Upgrade vit to non vulnerable one by @adrien2p in #14042
  • chore(order): custom display id by @adrien2p in #14024
  • chore(event-bus-*): Do not emit if no subscribers: by @adrien2p in #14084
  • chore(): Improve product list when there is a single sales channel by @adrien2p in #14082
  • chore: fix payloads of events in TSDocs + description of emitEventStep by @shahednasser in #14132
  • chore(): Promotion auto managed joiner config by @adrien2p in #14115
  • chore: Update medusa exec worker mode by @adrien2p in #14145
  • chore: improve and add TSDocs for next release by @shahednasser in #14170
  • chore: improve completeCartWorkflow TSDocs by @shahednasser in #14153
  • chore: change 2.11.4 to 2.12.0 in TSDocs by @shahednasser in #14174

Other Changes

New Contributors

Full Changelog: v2.11.3...v2.12.0

Don't miss a new medusa release

NewReleases is sending notifications on new releases.