diff --git a/packages/core/src/config/catalog/default-product-variant-price-calculation-strategy.spec.ts b/packages/core/src/config/catalog/default-product-variant-price-calculation-strategy.spec.ts index c6bc8f89ce..257069b0f8 100644 --- a/packages/core/src/config/catalog/default-product-variant-price-calculation-strategy.spec.ts +++ b/packages/core/src/config/catalog/default-product-variant-price-calculation-strategy.spec.ts @@ -1,6 +1,7 @@ import { beforeAll, beforeEach, describe, expect, it } from 'vitest'; import { roundMoney } from '../../common/round-money'; +import { ProductVariant } from '../../entity/index'; import { createRequestContext, MockTaxRateService, @@ -19,6 +20,7 @@ import { DefaultProductVariantPriceCalculationStrategy } from './default-product describe('DefaultProductVariantPriceCalculationStrategy', () => { let strategy: DefaultProductVariantPriceCalculationStrategy; const inputPrice = 6543; + const productVariant = new ProductVariant({}); beforeAll(async () => { await ensureConfigLoaded(); @@ -42,6 +44,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryStandard, activeTaxZone: zoneDefault, ctx, + productVariant, }); expect(result).toEqual({ @@ -57,6 +60,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryReduced, activeTaxZone: zoneDefault, ctx, + productVariant, }); expect(result).toEqual({ @@ -72,6 +76,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryStandard, activeTaxZone: zoneOther, ctx, + productVariant, }); expect(result).toEqual({ @@ -87,6 +92,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryReduced, activeTaxZone: zoneOther, ctx, + productVariant, }); expect(result).toEqual({ @@ -102,6 +108,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryReduced, activeTaxZone: zoneWithNoTaxRate, ctx, + productVariant, }); expect(result).toEqual({ @@ -119,6 +126,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryStandard, activeTaxZone: zoneDefault, ctx, + productVariant, }); expect(result).toEqual({ @@ -134,6 +142,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryReduced, activeTaxZone: zoneDefault, ctx, + productVariant, }); expect(result).toEqual({ @@ -149,6 +158,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryStandard, activeTaxZone: zoneOther, ctx, + productVariant, }); expect(result).toEqual({ @@ -164,6 +174,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryReduced, activeTaxZone: zoneOther, ctx, + productVariant, }); expect(result).toEqual({ @@ -179,6 +190,7 @@ describe('DefaultProductVariantPriceCalculationStrategy', () => { taxCategory: taxCategoryStandard, activeTaxZone: zoneWithNoTaxRate, ctx, + productVariant, }); expect(result).toEqual({ diff --git a/packages/core/src/config/catalog/product-variant-price-calculation-strategy.ts b/packages/core/src/config/catalog/product-variant-price-calculation-strategy.ts index a68578e2fd..cd87ce5d45 100644 --- a/packages/core/src/config/catalog/product-variant-price-calculation-strategy.ts +++ b/packages/core/src/config/catalog/product-variant-price-calculation-strategy.ts @@ -1,6 +1,7 @@ import { RequestContext } from '../../api/common/request-context'; import { PriceCalculationResult } from '../../common/types/common-types'; import { InjectableStrategy } from '../../common/types/injectable-strategy'; +import { ProductVariant } from '../../entity/product-variant/product-variant.entity'; import { TaxCategory } from '../../entity/tax-category/tax-category.entity'; import { Zone } from '../../entity/zone/zone.entity'; @@ -26,11 +27,14 @@ export interface ProductVariantPriceCalculationStrategy extends InjectableStrate * @description * The arguments passed the `calculate` method of the configured {@link ProductVariantPriceCalculationStrategy}. * + * The `productVariant` argument was added in v2.1.0. + * * @docsCategory products & stock * @docsPage ProductVariantPriceCalculationStrategy */ export interface ProductVariantPriceCalculationArgs { inputPrice: number; + productVariant: ProductVariant; taxCategory: TaxCategory; activeTaxZone: Zone; ctx: RequestContext; diff --git a/packages/core/src/service/helpers/product-price-applicator/product-price-applicator.ts b/packages/core/src/service/helpers/product-price-applicator/product-price-applicator.ts index 767c6efbf4..b32511e842 100644 --- a/packages/core/src/service/helpers/product-price-applicator/product-price-applicator.ts +++ b/packages/core/src/service/helpers/product-price-applicator/product-price-applicator.ts @@ -88,6 +88,7 @@ export class ProductPriceApplicator { const { price, priceIncludesTax } = await productVariantPriceCalculationStrategy.calculate({ inputPrice: channelPrice.price, taxCategory: variant.taxCategory, + productVariant: variant, activeTaxZone, ctx, });