@lana-commerce/core 14.0.0-alpha.20 → 14.0.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,24 +6,30 @@ function pricingForPricingRuleID(v, prID) {
6
6
  const po = v.pricing_overrides.find((po) => { var _a; return ((_a = po.pricing_rule) === null || _a === void 0 ? void 0 : _a.id) === prID; });
7
7
  return po
8
8
  ? {
9
- price: po.price,
10
- map_price: po.map_price,
11
- retail_price: po.retail_price,
12
- tiered_pricing: po.tiered_pricing,
13
- currency_prices: po.currency_prices,
9
+ pricing: {
10
+ price: po.price,
11
+ map_price: po.map_price,
12
+ retail_price: po.retail_price,
13
+ tiered_pricing: po.tiered_pricing,
14
+ currency_prices: po.currency_prices,
15
+ },
16
+ match: true,
14
17
  }
15
18
  : {
16
- price: v.price,
17
- map_price: v.map_price,
18
- retail_price: v.retail_price,
19
- tiered_pricing: v.tiered_pricing,
20
- currency_prices: v.currency_prices,
19
+ pricing: {
20
+ price: v.price,
21
+ map_price: v.map_price,
22
+ retail_price: v.retail_price,
23
+ tiered_pricing: v.tiered_pricing,
24
+ currency_prices: v.currency_prices,
25
+ },
26
+ match: false,
21
27
  };
22
28
  }
23
29
  function variantLikeToStorefrontVariantPricer(v, pricingRuleID, parentPricingRuleID, displayPriceDifference) {
24
30
  const current = pricingForPricingRuleID(v, pricingRuleID);
25
- const previous = displayPriceDifference ? pricingForPricingRuleID(v, parentPricingRuleID) : null;
26
- return Object.assign(Object.assign({}, current), { previous_pricing: previous });
31
+ const previous = displayPriceDifference && current.match ? pricingForPricingRuleID(v, parentPricingRuleID) : null;
32
+ return Object.assign(Object.assign({}, current.pricing), { previous_pricing: (previous === null || previous === void 0 ? void 0 : previous.pricing) || null });
27
33
  }
28
34
  function variantPriceInfo(env, variant, pricingRuleID, parentPricingRuleID, displayPriceDifference) {
29
35
  const v = variantLikeToStorefrontVariantPricer(variant, pricingRuleID, parentPricingRuleID, displayPriceDifference);
@@ -3,26 +3,32 @@ function pricingForPricingRuleID(v, prID) {
3
3
  const po = v.pricing_overrides.find((po) => po.pricing_rule?.id === prID);
4
4
  return po
5
5
  ? {
6
- price: po.price,
7
- map_price: po.map_price,
8
- retail_price: po.retail_price,
9
- tiered_pricing: po.tiered_pricing,
10
- currency_prices: po.currency_prices,
6
+ pricing: {
7
+ price: po.price,
8
+ map_price: po.map_price,
9
+ retail_price: po.retail_price,
10
+ tiered_pricing: po.tiered_pricing,
11
+ currency_prices: po.currency_prices,
12
+ },
13
+ match: true,
11
14
  }
12
15
  : {
13
- price: v.price,
14
- map_price: v.map_price,
15
- retail_price: v.retail_price,
16
- tiered_pricing: v.tiered_pricing,
17
- currency_prices: v.currency_prices,
16
+ pricing: {
17
+ price: v.price,
18
+ map_price: v.map_price,
19
+ retail_price: v.retail_price,
20
+ tiered_pricing: v.tiered_pricing,
21
+ currency_prices: v.currency_prices,
22
+ },
23
+ match: false,
18
24
  };
19
25
  }
20
26
  function variantLikeToStorefrontVariantPricer(v, pricingRuleID, parentPricingRuleID, displayPriceDifference) {
21
27
  const current = pricingForPricingRuleID(v, pricingRuleID);
22
- const previous = displayPriceDifference ? pricingForPricingRuleID(v, parentPricingRuleID) : null;
28
+ const previous = displayPriceDifference && current.match ? pricingForPricingRuleID(v, parentPricingRuleID) : null;
23
29
  return {
24
- ...current,
25
- previous_pricing: previous,
30
+ ...current.pricing,
31
+ previous_pricing: previous?.pricing || null,
26
32
  };
27
33
  }
28
34
  export function variantPriceInfo(env, variant, pricingRuleID, parentPricingRuleID, displayPriceDifference) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lana-commerce/core",
3
- "version": "14.0.0-alpha.20",
3
+ "version": "14.0.0-alpha.21",
4
4
  "description": "Lana JS Core",
5
5
  "scripts": {
6
6
  "test": "jest",