Commit Graph

1424 Commits

Author SHA1 Message Date
Adrien de Peretti
8c29d85f0f feat(): remove status from translatable fields (#14321)
* feat(): remove status from translatable fields

* Create tender-mugs-shave.md

* feat(): remove status from translatable fields
2025-12-16 14:57:06 +01:00
Adrien de Peretti
ba6ed8d9dd feat(): Translation statistics (#14299)
* chore(): Translation statistics

* chore(): improve statistics performances

* add end point to get statistics

* add tests

* Create spicy-games-unite.md

* feat(): add material and fix tests

* feat(): add translatable api

* feat(): add translatable api

* fix tests

* fix tests

* fix tests

* feedback
2025-12-15 14:11:49 +01:00
Adrien de Peretti
0f1566c644 feat(): Add support for store locales end point (#14307)
**What**
Add support for `store/locales` which return the configured supported locales
2025-12-15 13:10:43 +00:00
Nicolas Gorga
8964a03fa1 chore(): Remove default_locale from StoreLocale (#14300)
## Summary

**What** — What changes are introduced in this PR?

Remove `default_locale` from Store <> Locale relation

**Why** — Why are these changes relevant or necessary?  

*Please provide answer here*

**How** — How have these changes been implemented?

*Please provide answer here*

**Testing** — How have these changes been tested, or how can the reviewer test the feature?

*Please provide answer here*

---

## Examples

Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.  
This helps with documentation and ensures maintainers can quickly understand and verify the change.

```ts
// Example usage
```

---

## Checklist

Please ensure the following before requesting a review:

- [ ] I have added a **changeset** for this PR
    - Every non-breaking change should be marked as a **patch**
    - To add a changeset, run `yarn changeset` and follow the prompts
- [ ] The changes are covered by relevant **tests**
- [ ] I have verified the code works as intended locally
- [ ] I have linked the related issue(s) if applicable

---

## Additional Context

Add any additional context, related issues, or references that might help the reviewer understand this PR.


Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-12-15 09:05:46 +00:00
Adrien de Peretti
f13c23a4b7 feat(): Sync order translations (#14267)
* feat(): Sync order translations

* feat(): Sync order translations

* tests

* Create tender-melons-develop.md

* fix tests

* cleanup

* cleanup
2025-12-11 15:40:11 +01:00
Nicolas Gorga
70929ecac3 fix(dashboard,medusa,types): improve performance for price list prices retrieval (#14138)
## Summary

**What** — What changes are introduced in this PR?

Price lists prices didn't have a dedicated method to query them and instead, relied on being returned as part of price lists. This, however, introduces optimization issues that for price lists with many prices, could cause crashes. The reason being that relations are not paginated and thus, all prices linked to the price list would be returned.

This PR aims to solve this by introducing a dedicated endpoint and avoiding returning the `prices` as part of price lists by default. The idea being that it is up to the user to explicitly express this, which, for small price lists no issues will arise, but for bigger ones, they will easily recognize the performance impact.

**Why** — Why are these changes relevant or necessary?  

Users with large enough price lists would have serious performance issues or even crashes when querying the `/admin/price-lists` endpoints. This is also true when navigating to the price list section of the Admin UI since it queries this same endpoints.

**How** — How have these changes been implemented?

- Removed the `prices` relation to be part of the default fields returned by the `/admin/price-lists/` endpoints. User may still request it by passing it in `fields` query param.
- Added new `/admin/price-lists/[id]/prices` GET endpoint to be able to retrieve a price list prices with pagination.

**Testing** — How have these changes been tested, or how can the reviewer test the feature?

Integration tests.

---

## Examples

Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.  
This helps with documentation and ensures maintainers can quickly understand and verify the change.

```ts
// Example usage
```

---

## Checklist

Please ensure the following before requesting a review:

- [x] I have added a **changeset** for this PR
    - Every non-breaking change should be marked as a **patch**
    - To add a changeset, run `yarn changeset` and follow the prompts
- [x] The changes are covered by relevant **tests**
- [x] I have verified the code works as intended locally
- [x] I have linked the related issue(s) if applicable

---

## Additional Context

The current state of the PR fixes the issue on the price list list and detail component. It still doesn't solve the issue for the following screens: Edit Prices & Add Prices

All the prices are still retrieved from the `/admin/price-lists/` endpoint for these. I want first some feedback before changing it to the new endpoint, since the current DataGrid implementation doesn't support pagination and it seems we are passing a default limit for the products to show there, an arbitrarily large number 9999 and there is also a TODO comment of changing that.

This previous point, though, could be implemented in a later PR, so we can already fix the issue in the price list list and detail pages, so at least for large price lists these screens don't explode and smaller price lists can still have its product prices edited, while only large ones will explode when trying to perform this action. @adrien2p @fPolic thoughts?

closes ENTSUP-265, CORE-1239
2025-12-11 13:13:08 +00:00
olivermrbl
237b472e73 chore: Version packages 2025-12-11 14:10:54 +01:00
Nicolas Gorga
d565a92f63 fix(core-flows): refresh payment collection inside updateCartPromotionsWorkflow (patch) (#14274)
* Refresh payment collection after cart promotion update

* Add missing test

* Add changeset

* Update changeset

* Add force_refresh_payment_collection to updateCartPromotionsWorkflow to conditionally refresh payment collection

* Prevent refreshing payment collection multiple times

* Fix test

* Formatting and unused vars

* Force refresh payment collection on dedicated store cart promotion endpoints

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-12-11 10:29:52 +01:00
Adrien de Peretti
fd3965974d feat(): Pluralized props for list readonly link (#14190)
* feat(): Pluralized props for list readonly link

* Create perfect-jeans-end.md

* handle backward compat

* Add tests case
2025-12-10 19:38:06 +01:00
Adrien de Peretti
dd74ce34ba chore(): Add translations/locale integration tests and fix locale endpoint (#14266)
* chore(): Add translations/locale integration tests and fix locale end point

* Create selfish-dots-shop.md
2025-12-10 13:45:35 +01:00
Adrien de Peretti
e4877616c3 feat(): sync cart translation synced (#14226)
ref: https://github.com/medusajs/medusa/pull/14189

  **Summary**

  This PR extends the translation module to support automatic translation syncing for cart line items based on the cart's locale.

  Key changes:
  - Added locale field to the Cart model to store the cart's locale preference
  - Created new workflow steps:
    - getTranslatedLineItemsStep - Translates line items when adding to cart or creating a cart
    - updateCartItemsTranslationsStep - Re-translates all cart items when the cart's locale changes
  - Integrated translation logic into cart workflows:
    - createCartWorkflow - Applies translations to initial line items
    - addToCartWorkflow - Applies translations when adding new items
    - updateCartWorkflow - Re-translates all items when locale_code is updated
    - refreshCartItemsWorkflow - Maintains translations during cart refresh
  - Added applyTranslationsToItems utility to map variant/product/type/collection translations to line item fields (title, subtitle, description, etc.)
2025-12-10 08:37:30 +00:00
Nicolas Gorga
fdc2b722d9 fix(core-flows, medusa): Prevent cart addresses duplication on update (#13841)
* Allow id field in addresses properties for cart update validator

* Update cart addresses in update step where id is provided, both reference and nested fields

* Add tests

* Add changeset

* Remove unnecessary map step

* Review changes
2025-12-09 21:49:16 -03:00
Adrien de Peretti
6dc0b8bed8 feat(): Introduce translation module and preliminary application of them (#14189)
* feat(): Translation first steps

* feat(): locale middleware

* feat(): readonly links

* feat(): feature flag

* feat(): modules sdk

* feat(): translation module re export

* start adding workflows

* update typings

* update typings

* test(): Add integration tests

* test(): centralize filters preparation

* test(): centralize filters preparation

* remove unnecessary importy

* fix workflows

* Define StoreLocale inside Store Module

* Link definition to extend Store with supported_locales

* store_locale migration

* Add supported_locales handling in Store Module

* Tests

* Accept supported_locales in Store endpoints

* Add locales to js-sdk

* Include locale list and default locale in Store Detail section

* Initialize local namespace in js-sdk

* Add locales route

* Make code primary key of locale table to facilitate upserts

* Add locales routes

* Show locale code as is

* Add list translations api route

* Batch endpoint

* Types

* New batchTranslationsWorkflow and various updates to existent ones

* Edit default locale UI

* WIP

* Apply translation agnostically

* middleware

* Apply translation agnostically

* fix Apply translation agnostically

* apply translations to product list

* Add feature flag

* fetch translations by batches of 250 max

* fix apply

* improve and test util

* apply to product list

* dont manage translations if no locale

* normalize locale

* potential todo

* Protect translations routes with feature flag

* Extract normalize locale util to core/utils

* Normalize locale on write

* Normalize locale for read

* Use feature flag to guard translations UI across the board

* Avoid throwing incorrectly when locale_code not present in partial updates

* move applyTranslations util

* remove old tests

* fix util tests

* fix(): product end points

* cleanup

* update lock

* remove unused var

* cleanup

* fix apply locale

* missing new dep for test utils

* Change entity_type, entity_id to reference, reference_id

* Remove comment

* Avoid registering translations route if ff not enabled

* Prevent registering express handler for disabled route via defineFileConfig

* Add tests

* Add changeset

* Update test

* fix integration tests, module and internals

* Add locale id plus fixed

* Allow to pass array of reference_id

* fix unit tests

* fix link loading

* fix store route

* fix sales channel test

* fix tests

---------

Co-authored-by: Nicolas Gorga <nicogorga11@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-12-08 19:33:08 +01:00
Nicolas Gorga
fea3d4ec49 fix(core-flows): Access orderItem.variant safely inside convertDraftOrderWorkflow when containing custom items (#14233)
* Access orderItem variant safely on convert draft order workflow

* Tests

* Add changest

* Remove .only from test
2025-12-08 08:56:05 -03:00
Frane Polić
6176f93ac5 fix(dashboard,order): preview pending diff summary (#14221)
* wip: preview pending diff summary

* fix: return test

* fix: rm return calc from processAction_

* chore: cleanup

* chore: changeset

* feat: add estimated diff for return,claim,exchange forms

* chore: changeset
2025-12-08 09:57:13 +01:00
Nicolas Gorga
842c0f5007 fix(core-flows): refresh payment collection inside updateCartPromotionsWorkflow (#13963)
* Refresh payment collection after cart promotion update

* Add missing test

* Add changeset

* Update changeset

* Add force_refresh_payment_collection to updateCartPromotionsWorkflow to conditionally refresh payment collection

* Prevent refreshing payment collection multiple times

* Fix test

* Formatting and unused vars

---------

Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
2025-12-05 15:27:21 -03:00
olivermrbl
ba275a33bb chore: Version packages 2025-12-03 09:20:02 +01:00
Adrien de Peretti
391d8dc6cd fix(): event emitting (#14196)
* fix(): event emitting

* Create rude-queens-deny.md

* fix(): store subscriber should not be constraint

* Update rude-queens-deny.md

* Add tests to prevent regression
2025-12-03 08:53:09 +01:00
olivermrbl
1d4af32749 chore: Version packages 2025-12-01 18:54:07 +01:00
Frane Polić
8ddf8b4d76 fix: skip promotion usage limit checks on edit flows (#14176)
* fix: skip promotion usage limit checks on edit flows

* feat: add test check
2025-12-01 18:29:15 +01:00
Nicolas Gorga
3e2991e447 fix(core-flows): create reservations on draft order conversion to regular order (#14010)
## Summary

**What** — What changes are introduced in this PR?

Avoid creating reservations when draft order edits are confirmed and rather, create them when the draft order is converted into a regular order.

**Why** — Why are these changes relevant or necessary?  

While the order is a draft, creating reservations would potentially block inventory for regular order requests, when the draft represents a non materialized state of a purchase that might never be completed or at a latter point in time.

**How** — How have these changes been implemented?

Removed the reservation creations inside of `confirmDraftOrderEditWorkflow` and instead do it inside `convertDraftOrderWorkflow`

**Testing** — How have these changes been tested, or how can the reviewer test the feature?

Added integration tests.

---

## Examples

Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.  
This helps with documentation and ensures maintainers can quickly understand and verify the change.

```ts
// Example usage
```

---

## Checklist

Please ensure the following before requesting a review:

- [x] I have added a **changeset** for this PR
    - Every non-breaking change should be marked as a **patch**
    - To add a changeset, run `yarn changeset` and follow the prompts
- [x] The changes are covered by relevant **tests**
- [x] I have verified the code works as intended locally
- [x] I have linked the related issue(s) if applicable

---

## Additional Context

Add any additional context, related issues, or references that might help the reviewer understand this PR.

fixes #13773 
closes SUP-2523
2025-12-01 12:08:03 +00:00
Frane Polić
536a3f802c feat: promotion usage limit (#13760)
* feat: promotion usage limit

* fix: update, refactor tests, parallel case

* fix: batch update, cleanup unused map

* feat: paralel campaign and promotion tests

* chore: changesets, fix i18 schema

* fix: ui tweaks

* chore: refactor

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-11-30 19:43:36 +01:00
Frane Polić
5da51064d7 feat: carry over promotions toggle on exchanges (#14128)
* feat: carry over promotions toggle on exchanges

* fix: inital flag value, return the flag on preview

* fix: validation of allocation type

* fix: revert client changes

* fix: invert condition

* feat: recompute adjustments when outbound item is updated

* fix: condition again

* fix: display more accurate inbound/outbound totals for exchanges

* fix: make exchanges specs green

* feat: more testing cases

* wip: pr feedback

* fix: use plural for the flag on Admin

* fix: schema test, route refactor

* feat: tooltip

* feat: refactor to use update workflow

* feat: display applied promotion per item on order details, show copy sku on hover

* feat: refactor edits and exchanges to have common flag toggle flow

* fix: delete empty file

* fix: exchange_id param query
2025-11-30 19:31:31 +01:00
Oli Juhl
78842af1c3 fix: Compute "virtual" adjustments for order previews (#13306)
* wip

* add wip

* wip

* reuse action

* finish first draft

* fix tests

* cleanup

* Only compute adjustments when necessary

* Create hot-carrots-look.md

* address comments

* minor tweaks

* fix pay col

* fix test

* wip

* Dwip

* wip

* fix: adjustment typo

* fix: import

* fix: workflow imports

* wip: update test

* feat: upsert versioned  adjustments when previewing order

* fix: revert unique codes change

* fix: order spec test with versioning

* wip: save

* feat: make adjustments work for preview and confirm flow, wip base repo filtering of older version adjustments

* fix: missing populate where

* wip: populate where loading versioned adjustments

* fix: filter out older adjustment versions

* temp: comment adjustments in repo

* test: add adjustment if no version

* wip: configure populate where in order base repository

* fix: rm manual filtering

* fix: revert base repo changes

* fix: revert

* fix: use order item version instead of order version

* fix: rm only in test

* fix: update case spec

* fix: remove sceanrio, wip test with draft promotion

* feat: test correct adjustments when disabling promotion

* feat: complex test case

* feat: test consecutive order edits

* feat: 2 promotions test case with a fixed promo

* feat: migrate existing order line item adjustments to order items latest version

* feat: update dep after merge

* wip: load adjustments separatley

* feat: adjustments collections

* fix: spread result, handle related entity case

* fix: update lock

* feat: make sure version is loaded, refactor, handle related entity case

* fix: check fields

* feat: loading adjustments for list and count

* fix: correct items version field

* fix: rm empty array

* fix: wip order modules spec

* fix: order module specs

* feat: preinit items adjustments

* fix: rm only

* fix: rm only

* chore: cleanup

* fix: migration files

* fix: dont change formatting

* fix: core package build

* chore: more cleanup

* fix: item update util

* fix: duplicate import

* fix: refresh adjustments for exchanges (#13992)

* wip: exchange adjustments

* feat: test - receive items

* feat: finish test case

* fix: casing

* fix(draft-orders, core-flows, orders) refresh adjustments for draft orders (#14025)

* wip: draft orders adjustments refresh

* feat: rewrite to use REPLACE action + test

* fix: rm only

* feat: cleanup old REPLACE actions

* feat: cleanup adjustemnts when 0 promotions

* wip: canceling draft order

* fix: make version arg optional

* fix: restore promotion links

* feat: test reverting on cancelation

* fix: address comments in tests

* wip: fix summary on preview

* fix: get pending diff on preview summary from total

* fix: revert pending diff change

---------

Co-authored-by: fPolic <mainacc.polic@gmail.com>
Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>
2025-11-25 10:41:14 +01:00
Adrien de Peretti
113f200a99 chore(event-bus-*): Do not emit if no subscribers: (#14084)
* chore(event-vus-*): Do not emit if no subscribers:

* Create curly-apricots-double.md

* add tests

* align tests
2025-11-24 09:36:52 +01:00
Nicolas Gorga
79582bc94e fix(core-flows): prevent completing cart from webhook when order already exists (#14108)
* Prevent completing cart when order already exists in processPaymentWorkflow

* Add tests

* Add changeset
2025-11-24 09:23:39 +01:00
Nicolas Gorga
32eaa9dd81 fix(medusa): avoid throwing on error on set step failure endpoint (#14066)
* Avoid throwing on setStepFailure endpoint

* Add changeset

* Add tests
2025-11-23 07:04:39 -03:00
Adrien de Peretti
6746fecd72 chore(order): custom display id (#14024)
* chore(order): Accept a custom display generator option

* chore(order): Accept a custom display generator option

* wip

* wip

* finalize

* Create tricky-olives-battle.md

* fields

* changeset

* update integration tests

* update migrations

* fix changeset
2025-11-18 10:17:46 +01:00
Dhanush Reddy
178b1e2b47 fix some typos (#14017)
Co-authored-by: William Bouchard <46496014+willbouch@users.noreply.github.com>
2025-11-14 15:54:28 +02:00
Govind
5499cd2749 fix(core-flows): payment error handling (#13876)
* fix: payment error handling

* Create dirty-radios-kiss.md

* fix: updated to use isMedusaError

* fix: error message updated and error type corrected

---------

Co-authored-by: William Bouchard <46496014+willbouch@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-11-07 07:57:44 -05:00
Nicolas Gorga
6b4f2c1d32 feat(medusa): allow users deletion (#13960)
## Summary

**What** — What changes are introduced in this PR?

Allow users to delete other users and prevent them from deleting themselves.

**Why** — Why are these changes relevant or necessary?  

Inability to delete other users causes old users that maybe don't work anymore with the business to have access still.

**How** — How have these changes been implemented?

Inverted the check in the admin delete user endpoint, to allow users deleting other users but themselves.

**Testing** — How have these changes been tested, or how can the reviewer test the feature?

Integration tests

---

## Examples

Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.  
This helps with documentation and ensures maintainers can quickly understand and verify the change.

```ts
// Example usage
```

---

## Checklist

Please ensure the following before requesting a review:

- [x] I have added a **changeset** for this PR
    - Every non-breaking change should be marked as a **patch**
    - To add a changeset, run `yarn changeset` and follow the prompts
- [x] The changes are covered by relevant **tests**
- [x] I have verified the code works as intended locally
- [x] I have linked the related issue(s) if applicable

---

## Additional Context

Add any additional context, related issues, or references that might help the reviewer understand this PR.

closes OPS-97


---

> [!NOTE]
> Enables deleting other users via admin DELETE endpoint while blocking self-deletion, with corresponding integration tests and changeset.
> 
> - **Backend**
>   - Update `DELETE /admin/users/:id` in `packages/medusa/src/api/admin/users/[id]/route.ts`:
>     - Disallow self-deletion when `actor_id === id` with `NOT_ALLOWED` error.
>     - Execute `removeUserAccountWorkflow` and return standard delete response.
> - **Tests**
>   - Expand `integration-tests/http/__tests__/user/admin/user.spec.ts`:
>     - Create a second admin user; delete it and verify auth identity `app_metadata` no longer includes `user_id`.
>     - Confirm token still authenticates but access is revoked (401 on `/admin/users/me`).
>     - Assert self-deletion returns 400 with message `"A user cannot delete itself"`.
> - **Changeset**
>   - Add `.changeset/dull-plants-create.md` (patch for `@medusajs/medusa`).
> 
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f1f8252b91593b8a8fb03dc9d26460d09a10cfaa. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
2025-11-07 09:24:04 +00:00
github-actions[bot]
645266c200 chore: Version Packages (#13923)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-11-05 12:52:44 +01:00
Adrien de Peretti
9d9d0397a8 fix(): Index integration tests flackyness (#13953)
* fix(): Index integration tests flackyness

* fix

* Create twenty-eels-remain.md

* fix

* fix

* fix

* fix

* finalize

* finalize

* finalize

* finalize

* finalize

* finalize

* chore: empty commit

* finalize

* finalize

* chore: empty commit

* finalize

* finalize
2025-11-05 10:40:12 +01:00
Adrien de Peretti
37563987b8 chore(): Fix dependencies (#13932) 2025-11-02 17:46:46 +01:00
Carlos R. L. Rodrigues
990691e78a chore(medusa): do not use transaction id on cart operations (#13931) 2025-10-31 15:09:35 -03:00
Adrien de Peretti
224ab39a81 chore(): Update dependencies usage (#13910)
* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* fix for wxios 1.6

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* push scripts

* update build concurrency

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* chore(): Update dependencies usage

* fixes

* update yarn

* fixes

* fix script

* Create heavy-suns-tickle.md

* update changeset

---------

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
2025-10-31 16:44:14 +01:00
Adrien de Peretti
4e5b318583 fix(): update Integration test enabling index when not necessary (#13904)
* fix(): update Integration test enabling index when not necessary

* fix
2025-10-31 15:51:26 +01:00
github-actions[bot]
31b9ae3d28 chore: Version Packages (#13853)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-10-31 10:11:18 +01:00
Adrien de Peretti
85b1f3d43a feat(index): Add http/module api to interact with the index engine (#13869)
* feat(index): Add support to trigger sync manually

* feat(index): Add API route to interact with

* feat(index): Add API route to interact with

* feat(index): Add API route to interact with

* test(): Add http integration tests

* Create weak-elephants-reply.md
2025-10-28 20:31:39 +01:00
Frane Polić
25a20ca95f feat(medusa,types): product variant store endpoints (#13730)
* wip(medusa): product variant store endpoints

* chore: refactor types

* chore: changesets

* fix: address feedback 1

* feat: load images for variants by default

* fix: use query.graph directly instead of refetchEntity

* feat: enable cache for variants endpoint
2025-10-28 10:12:07 +01:00
Frane Polić
4757281677 feat(core-flows,product,types): scoped variant images (#13623)
* wip(product): variant images

* fix: return type

* wip: repo and list approach

* fix: redo repo method, make test pass

* fix: change getVariantImages impl

* feat: update test

* feat: API and core flows layer

* wip: integration spec

* fix: deterministic test

* chore: refactor and simplify, cleanup, remove repo method

* wip: batch add all images to all vairants

* fix: remove, expand testing

* refactor: pass variants instead of refetch

* chore: expand integration test

* feat: test multi assign route

* fix: remove `/admin/products/:id/variants/images` route

* feat: batch images to variant endpoint

* fix: length assertion

* feat: variant thumbnail

* fix: send variant thumbnail by default

* fix: product export test assertion

* fix: test

* feat: variant thumbnail on line item

* fix: add missing list and count method, update types

* feat: optimise variant images lookups

* feat: thumbnail management in core flows

* fix: typos, type, build

* feat: cascade delete to pivot table, rm unused unused fields

* feat(dashboard): variant images management UI (#13670)

* wip(dashboard): setup variant media form

* wip: cleanup table and images, wip check handler

* feat: proper sidebar functionallity

* fefat: add js-sdk and hooks

* feat: allow only one selection

* wip: lazy load variants in the table

* feat: new variants management for images on product details

* chore: refactor

* wip: variant details page work

* fix: cleanup media section, fix issues and types

* feat: correct scoped images, cleanup in edit modal

* feat: js sdk and hooks, filter out product images on variant details, labels, add API call and wrap UI

* chore: cleanup

* refacto: rename route

* feat: thumbnail functionallity

* fix: refresh checked after revalidation load

* fix: rm unused, refactor type

* Create thirty-clocks-refuse.md

* feat: new add remove variant media layout

* feat: new image add UX

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

* fix: table name in migration

* chore: update changesets

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-10-26 15:15:40 +01:00
github-actions[bot]
6e73f8b376 chore: Version Packages (#13800)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-10-25 21:52:10 +02:00
Oli Juhl
f055bfd723 fix(pricing): Update store + list price preferences (#13852)
* fix(pricing): Update store + list price preferencs

* Create afraid-kids-return.md
2025-10-25 21:45:26 +02:00
github-actions[bot]
e47f0d0271 chore: Version Packages (#13545)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-10-21 09:24:59 +02:00
Adrien de Peretti
516f5a3896 fix: workflow async concurrency (#13769)
* executeAsync

* || 1

* wip

* stepId

* stepId

* wip

* wip

* continue versioning management changes

* fix and improve concurrency

* update in memory engine

* remove duplicated test

* fix script

* Create weak-drinks-confess.md

* fixes

* fix

* fix

* continuation

* centralize merge checkepoint

* centralize merge checkpoint

* fix locking

* rm only

* Continue improvements and fixes

* fixes

* fixes

* hasAwaiting will be recomputed

* fix orchestrator engine

* bump version on async parallel steps only

* mark as delivered fix

* changeset

* check partitions

* avoid saving when having parent step

* cart test

---------

Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-10-20 15:29:19 +02:00
Oli Juhl
b5ecdfcd12 feat: Add allocation method type ONCE (#13700)
### What
Add a new `once` allocation strategy to promotions that limits application to a maximum number of items across the entire cart, rather than per line item.

### Why
Merchants want to create promotions that apply to a limited number of items across the entire cart. For example:
- "Get $10 off, applied to one item only"
- "20% off up to 2 items in your cart"

Current allocation strategies:
- `each`: Applies to each line item independently (respects `max_quantity` per item)
- `across`: Distributes proportionally across all items

Neither supports limiting total applications across the entire cart.

### How

Add `once` to the `ApplicationMethodAllocation` enum.

Behavior:
- Applies promotion to maximum `max_quantity` items across entire cart
- Always prioritizes lowest-priced eligible items first
- Distributes sequentially across items until quota exhausted
- Requires `max_quantity` field to be set

### Example Usage

**Scenario 1: Fixed discount**
```javascript
{
  type: "fixed",
  allocation: "once",
  value: 10,        // $10 off
  max_quantity: 2   // Apply to 2 items max across cart
}

Cart:
- Item A: 3 units @ $100/unit
- Item B: 5 units @ $50/unit (lowest price)

Result: $20 discount on Item B (2 units × $10)
```

**Scenario 2: Distribution across items**
```javascript
{
  type: "fixed",
  allocation: "once",
  value: 5,
  max_quantity: 4
}

Cart:
- Item A: 2 units @ $50/unit
- Item B: 3 units @ $60/unit

Result:
- Item A: $10 discount (2 units × $5)
- Item B: $10 discount (2 units × $5, remaining quota)
```

**Scenario 3: Percentage discount - single item**
```javascript
{
  type: "percentage",
  allocation: "once",
  value: 20,         // 20% off
  max_quantity: 3    // Apply to 3 items max
}

Cart:
- Item A: 5 units @ $100/unit
- Item B: 4 units @ $50/unit (lowest price)

Result: $30 discount on Item B (3 units × $50 × 20% = $30)
```

**Scenario 4: Percentage discount - distributed across items**
```javascript
{
  type: "percentage",
  allocation: "once",
  value: 15,         // 15% off
  max_quantity: 5
}

Cart:
- Item A: 2 units @ $40/unit (lowest price)
- Item B: 4 units @ $80/unit

Result:
- Item A: $12 discount (2 units × $40 × 15% = $12)
- Item B: $36 discount (3 units × $80 × 15% = $36, remaining quota)
Total: $48 discount
```

**Scenario 5: Percentage with max_quantity = 1**
```javascript
{
  type: "percentage",
  allocation: "once",
  value: 25,         // 25% off
  max_quantity: 1    // Only one item
}

Cart:
- Item A: 3 units @ $60/unit
- Item B: 2 units @ $30/unit (lowest price)

Result: $7.50 discount on Item B (1 unit × $30 × 25%)
```
2025-10-14 11:01:00 +00:00
Oli Juhl
1d2b4566fd chore: Ensure refund doesn't exceed captured amount (#13744)
* wip

* chore: prepare for PR

* move to end

* Change order of operations in refundPaymentWorkflow

Updated the order of operations in the refundPaymentWorkflow.

* chore: Add validation
2025-10-13 22:09:46 +02:00
Adrien de Peretti
c54c5ed6de chore(): improve cart operations + Mikro orm 6.4.16 (#13712)
* chore(): Mikro orm 6.4.16

* Create small-ghosts-draw.md

* update config

* update config

* fix delete

* update config

* update workflows

* order improvements

* test pricing quuery

* test pricing quuery

* configurable connection options

* configurable connection options

* configurable connection options

* Update packages/modules/pricing/src/models/price.ts

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2025-10-10 08:58:19 +02:00
Frane Polić
7dc3b0c5ff feat(core-flows,dashboard,js-sdk,promotion,medusa,types,utils): limit promotion usage per customer (#13451)
**What**
- implement promotion usage limits per customer/email
- fix registering spend usage over the limit
- fix type errors in promotion module tests

**How**
- introduce a new type of campaign budget that can be defined by an attribute such as customer id or email
- add `CampaignBudgetUsage` entity to keep track of the number of uses per attribute value
- update `registerUsage` and `computeActions` in the promotion module to work with the new type
- update `core-flows` to pass context needed for usage calculation to the promotion module

**Breaking**
- registering promotion usage now throws (and cart complete fails) if the budget limit is exceeded or if the cart completion would result in a breached limit

---

CLOSES CORE-1172
CLOSES CORE-1173
CLOSES CORE-1174
CLOSES CORE-1175


Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2025-10-09 12:35:54 +00:00
William Bouchard
924564bee5 fix(core-flows): customer id filter not working in getOrderDetails (#13695)
As discussed, fixed the get order detail and also changed the remotequery to graph a bunch of workflows
2025-10-09 12:13:12 +00:00