Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smart-stamps-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/core-flows": patch
---

fix(core-flows): avoid overriding customer and region from setPricingContext hook result
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ export const getVariantsAndItemsWithPrices = createWorkflow(
const cart = data.cart
const baseContext = {
...filterObjectByKeys(cart, cartFieldsForPricingContext),
customer: cart.customer,
region: cart.region,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Pricing Context Ignores Custom Objects

After allowing setPricingContextResult to provide custom region and customer objects, the code still uses cart.region?.currency_code, cart.region_id, and cart.customer_id as fallbacks. This creates inconsistency when a custom region or customer is provided, causing the context to have mismatched IDs and currency codes that don't match the custom objects.

Fix in Cursor Fix in Web

...(data.setPricingContextResult ? data.setPricingContextResult : {}),
currency_code: cart.currency_code ?? cart.region?.currency_code,
region_id: cart.region_id,
region: cart.region,
customer_id: cart.customer_id,
customer: cart.customer,
}

return (data.items ?? cart.items ?? [])
Expand Down