@unchainedshop/core-products 4.0.2 → 4.1.1
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.
|
@@ -3,9 +3,9 @@ export const getPriceLevels = (params) => {
|
|
|
3
3
|
.toSorted(({ maxQuantity: leftMaxQuantity = 0 }, { maxQuantity: rightMaxQuantity = 0 }) => {
|
|
4
4
|
if (leftMaxQuantity === rightMaxQuantity || (!leftMaxQuantity && !rightMaxQuantity))
|
|
5
5
|
return 0;
|
|
6
|
-
if (leftMaxQuantity
|
|
6
|
+
if (!leftMaxQuantity)
|
|
7
7
|
return 1;
|
|
8
|
-
if (rightMaxQuantity
|
|
8
|
+
if (!rightMaxQuantity)
|
|
9
9
|
return -1;
|
|
10
10
|
return leftMaxQuantity - rightMaxQuantity;
|
|
11
11
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPriceLevels.js","sourceRoot":"","sources":["../../../src/module/utils/getPriceLevels.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAI9B,EAAE,EAAE;IACH,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC;SAC7C,QAAQ,CAAC,CAAC,EAAE,WAAW,EAAE,eAAe,GAAG,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,gBAAgB,GAAG,CAAC,EAAE,EAAE,EAAE;QACxF,IAAI,eAAe,KAAK,gBAAgB,IAAI,CAAC,CAAC,eAAe,IAAI,CAAC,gBAAgB,CAAC;YAAE,OAAO,CAAC,CAAC;QAC9F,IAAI,eAAe
|
|
1
|
+
{"version":3,"file":"getPriceLevels.js","sourceRoot":"","sources":["../../../src/module/utils/getPriceLevels.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAI9B,EAAE,EAAE;IACH,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC;SAC7C,QAAQ,CAAC,CAAC,EAAE,WAAW,EAAE,eAAe,GAAG,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,gBAAgB,GAAG,CAAC,EAAE,EAAE,EAAE;QACxF,IAAI,eAAe,KAAK,gBAAgB,IAAI,CAAC,CAAC,eAAe,IAAI,CAAC,gBAAgB,CAAC;YAAE,OAAO,CAAC,CAAC;QAC9F,IAAI,CAAC,eAAe;YAAE,OAAO,CAAC,CAAC;QAC/B,IAAI,CAAC,gBAAgB;YAAE,OAAO,CAAC,CAAC,CAAC;QACjC,OAAO,eAAe,GAAG,gBAAgB,CAAC;IAC5C,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;QACrB,IAAI,CAAC,MAAM,CAAC,YAAY;YAAE,OAAO,UAAU,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,CAAC;QAC/E,OAAO,CACL,UAAU,CAAC,YAAY,KAAK,MAAM,CAAC,YAAY,IAAI,UAAU,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,CACjG,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-products",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"main": "lib/products-index.js",
|
|
5
5
|
"types": "lib/products-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@unchainedshop/events": "^4.
|
|
35
|
-
"@unchainedshop/file-upload": "^4.
|
|
36
|
-
"@unchainedshop/utils": "^4.
|
|
34
|
+
"@unchainedshop/events": "^4.1.0",
|
|
35
|
+
"@unchainedshop/file-upload": "^4.1.0",
|
|
36
|
+
"@unchainedshop/utils": "^4.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^24.0.13",
|
|
@@ -22,14 +22,6 @@ describe('Price level', () => {
|
|
|
22
22
|
]);
|
|
23
23
|
assert.strictEqual(getPriceLevels({ product, countryCode: 'CH' } as any).length, 3);
|
|
24
24
|
assert.deepStrictEqual(getPriceLevels({ product, countryCode: 'CH' } as any), [
|
|
25
|
-
{
|
|
26
|
-
amount: 1000,
|
|
27
|
-
maxQuantity: null,
|
|
28
|
-
isTaxable: false,
|
|
29
|
-
isNetPrice: false,
|
|
30
|
-
currencyCode: 'CHF',
|
|
31
|
-
countryCode: 'CH',
|
|
32
|
-
},
|
|
33
25
|
{
|
|
34
26
|
amount: 1,
|
|
35
27
|
maxQuantity: 1,
|
|
@@ -46,11 +38,6 @@ describe('Price level', () => {
|
|
|
46
38
|
currencyCode: 'CHF',
|
|
47
39
|
countryCode: 'CH',
|
|
48
40
|
},
|
|
49
|
-
]);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('Should return all prices for a given country sorted by max quantity ASC', () => {
|
|
53
|
-
assert.deepStrictEqual(getPriceLevels({ product, countryCode: 'CH' } as any), [
|
|
54
41
|
{
|
|
55
42
|
amount: 1000,
|
|
56
43
|
maxQuantity: null,
|
|
@@ -59,6 +46,11 @@ describe('Price level', () => {
|
|
|
59
46
|
currencyCode: 'CHF',
|
|
60
47
|
countryCode: 'CH',
|
|
61
48
|
},
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('Should return all prices for a given country sorted by max quantity ASC', () => {
|
|
53
|
+
assert.deepStrictEqual(getPriceLevels({ product, countryCode: 'CH' } as any), [
|
|
62
54
|
{
|
|
63
55
|
amount: 1,
|
|
64
56
|
maxQuantity: 1,
|
|
@@ -75,6 +67,14 @@ describe('Price level', () => {
|
|
|
75
67
|
currencyCode: 'CHF',
|
|
76
68
|
countryCode: 'CH',
|
|
77
69
|
},
|
|
70
|
+
{
|
|
71
|
+
amount: 1000,
|
|
72
|
+
maxQuantity: null,
|
|
73
|
+
isTaxable: false,
|
|
74
|
+
isNetPrice: false,
|
|
75
|
+
currencyCode: 'CHF',
|
|
76
|
+
countryCode: 'CH',
|
|
77
|
+
},
|
|
78
78
|
]);
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -8,8 +8,8 @@ export const getPriceLevels = (params: {
|
|
|
8
8
|
return (params.product?.commerce?.pricing || [])
|
|
9
9
|
.toSorted(({ maxQuantity: leftMaxQuantity = 0 }, { maxQuantity: rightMaxQuantity = 0 }) => {
|
|
10
10
|
if (leftMaxQuantity === rightMaxQuantity || (!leftMaxQuantity && !rightMaxQuantity)) return 0;
|
|
11
|
-
if (leftMaxQuantity
|
|
12
|
-
if (rightMaxQuantity
|
|
11
|
+
if (!leftMaxQuantity) return 1;
|
|
12
|
+
if (!rightMaxQuantity) return -1;
|
|
13
13
|
return leftMaxQuantity - rightMaxQuantity;
|
|
14
14
|
})
|
|
15
15
|
.filter((priceLevel) => {
|