Fix(medusa): make shipping option requirements tax inclusive if the shipping option is (#2544)
**What** - validate shipping option requirements including tax if the shipping option is tax inclusive **Testing** - " given a cart with total above min-threshold and subtotal below min-threshold shipping option with tax inclusive pricing is available and can be applied" - "given a cart with total above max-threshold and subtotal below max-threshold shipping option with tax inclusive pricing is not available" Fixes CORE-752
This commit is contained in:
1 parent
a68af8a474
commit
434b11af46
4 files changed
+316
-145
No files matched your search
@@ -1755,7 +1755,7 @@ class CartService extends TransactionBaseService {
|
||||
return await this.atomicPhase_(
|
||||
async (transactionManager: EntityManager) => {
|
||||
const cart = await this.retrieve(cartId, {
|
||||
select: ["subtotal"],
|
||||
select: ["subtotal", "total"],
|
||||
relations: [
|
||||
"shipping_methods",
|
||||
"discounts",
|
||||
|
||||
@@ -370,15 +370,15 @@ class ShippingOptionService extends TransactionBaseService {
|
||||
)
|
||||
}
|
||||
|
||||
const subtotal = cart.subtotal as number
|
||||
const amount = (option.includes_tax ? cart.total : cart.subtotal) as number
|
||||
|
||||
const requirementResults: boolean[] = option.requirements.map(
|
||||
(requirement) => {
|
||||
switch (requirement.type) {
|
||||
case "max_subtotal":
|
||||
return requirement.amount > subtotal
|
||||
return requirement.amount > amount
|
||||
case "min_subtotal":
|
||||
return requirement.amount <= subtotal
|
||||
return requirement.amount <= amount
|
||||
default:
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user