@ikas/storefront-model-functions 4.0.0-alpha.5 → 4.0.0-alpha.50
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront-model-functions",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.50",
|
|
4
4
|
"description": "Functions for ikas storefront models.",
|
|
5
5
|
"author": "Umut Ozan Yıldırım",
|
|
6
6
|
"license": "ISC",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"build": "rm -rf build && rollup -c"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
20
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
19
|
+
"@ikas/storefront-config": "^4.0.0-alpha.50",
|
|
20
|
+
"@ikas/storefront-models": "^4.0.0-alpha.50",
|
|
21
21
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
22
22
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
23
23
|
"@types/lodash": "^4.14.182",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"lodash": "^4.17.21"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
36
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
35
|
+
"@ikas/storefront-config": "^4.0.0-alpha.50",
|
|
36
|
+
"@ikas/storefront-models": "^4.0.0-alpha.50",
|
|
37
37
|
"lodash": "^4.17.21"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -61,7 +61,7 @@ export function getValidationResult(
|
|
|
61
61
|
country: !!address.country?.name,
|
|
62
62
|
state: !!address.state,
|
|
63
63
|
city: !!address.city?.name,
|
|
64
|
-
district: isDistrictRequired ? !!address.district?.
|
|
64
|
+
district: isDistrictRequired ? !!address.district?.name : true,
|
|
65
65
|
phone:
|
|
66
66
|
checkoutSettings.phoneRequirement === IkasCheckoutRequirement.MANDATORY ||
|
|
67
67
|
(checkoutSettings.phoneRequirement === IkasCheckoutRequirement.OPTIONAL &&
|
|
@@ -5,21 +5,15 @@ export function getPriceWithQuantity(item: IkasOrderLineItem) {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function getOverridenPriceWithQuantity(item: IkasOrderLineItem) {
|
|
8
|
-
|
|
9
|
-
item.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return price !== null && price < 0 ? 0 : price;
|
|
8
|
+
if (item.price !== item.finalPrice) {
|
|
9
|
+
return item.price * item.quantity;
|
|
10
|
+
} else {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export function getFinalPriceWithQuantity(item: IkasOrderLineItem) {
|
|
17
|
-
|
|
18
|
-
(item.discountPrice !== undefined && item.discountPrice !== null
|
|
19
|
-
? item.discountPrice
|
|
20
|
-
: item.price) * item.quantity;
|
|
21
|
-
|
|
22
|
-
return price < 0 ? 0 : price;
|
|
16
|
+
return (item.finalPrice ?? item.price) * item.quantity;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
export function getTax(item: IkasOrderLineItem) {
|
|
@@ -54,6 +54,8 @@ export function getDisplayedValues(filter: IkasProductFilter) {
|
|
|
54
54
|
IkasProductFilterSortType.ALPHABETICAL_DESC,
|
|
55
55
|
].includes(sortType);
|
|
56
56
|
|
|
57
|
+
const isCustomSort = sortType === IkasProductFilterSortType.CUSTOM_SORT;
|
|
58
|
+
|
|
57
59
|
let _values = filter.values?.filter((v) =>
|
|
58
60
|
v.resultCount === 0 ? v.isSelected : true
|
|
59
61
|
);
|
|
@@ -63,6 +65,13 @@ export function getDisplayedValues(filter: IkasProductFilter) {
|
|
|
63
65
|
|
|
64
66
|
if (isDesc) _values = _values?.reverse();
|
|
65
67
|
|
|
68
|
+
if (isCustomSort) {
|
|
69
|
+
const sortOrder = filter.settings?.customSortedValues || [];
|
|
70
|
+
_values = _values.sort(function (a, b) {
|
|
71
|
+
return sortOrder.indexOf(a.id) - sortOrder.indexOf(b.id);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
66
75
|
return _values;
|
|
67
76
|
}
|
|
68
77
|
|