@anker-in/shopify-react 0.1.1-beta.21 → 0.1.1-beta.22
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/dist/hooks/index.js +8 -6
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +7 -5
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.js +8 -6
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +7 -5
- package/dist/provider/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/hooks/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var shopifySdk = require('@anker-in/shopify-sdk');
|
|
|
6
6
|
var Cookies5 = require('js-cookie');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var Decimal2 = require('decimal.js');
|
|
9
|
+
var shopifyCore = require('@anker-in/shopify-core');
|
|
9
10
|
var useSWR = require('swr');
|
|
10
11
|
var ahooks = require('ahooks');
|
|
11
12
|
|
|
@@ -77,9 +78,10 @@ function normalizeAddToCartLines(lines) {
|
|
|
77
78
|
const variant = line.variant;
|
|
78
79
|
const product = variant.product;
|
|
79
80
|
const quantity = line.quantity || 1;
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
81
|
+
const originalPrice = variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : variant.price?.amount ? Number(variant.price.amount) : 0;
|
|
82
|
+
const finalPrice = variant.finalPrice?.amount ? Number(variant.finalPrice.amount) : originalPrice;
|
|
83
|
+
const subtotalAmount = originalPrice * quantity;
|
|
84
|
+
const totalAmount = finalPrice * quantity;
|
|
83
85
|
return {
|
|
84
86
|
id: `temp-line-${index}-${variant.id}`,
|
|
85
87
|
// Temporary ID for pre-cart lines
|
|
@@ -93,7 +95,7 @@ function normalizeAddToCartLines(lines) {
|
|
|
93
95
|
customAttributes: line.attributes || [],
|
|
94
96
|
variant: {
|
|
95
97
|
id: variant.id,
|
|
96
|
-
price,
|
|
98
|
+
price: variant.price?.amount ? Number(variant.price.amount) : 0,
|
|
97
99
|
listPrice: variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : 0,
|
|
98
100
|
sku: variant.sku || "",
|
|
99
101
|
name: variant.title || "",
|
|
@@ -170,7 +172,7 @@ var getMatchedMainProductSubTotal = (cartData, variant_list, main_product) => {
|
|
|
170
172
|
const matchedList = cartData?.lineItems?.filter((line) => {
|
|
171
173
|
const { is_gift } = getDiscountEnvAttributeValue(line.customAttributes);
|
|
172
174
|
return isAllStoreVariant ? !is_gift : variant_list?.find((item) => {
|
|
173
|
-
return !is_gift &&
|
|
175
|
+
return !is_gift && shopifyCore.atobID(line.variantId) === item;
|
|
174
176
|
});
|
|
175
177
|
});
|
|
176
178
|
return matchedList?.reduce((acc, line) => {
|
|
@@ -422,7 +424,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
422
424
|
if (!giftProduct) return null;
|
|
423
425
|
return {
|
|
424
426
|
variant: {
|
|
425
|
-
id:
|
|
427
|
+
id: shopifyCore.btoaID(giftProduct.variant_id),
|
|
426
428
|
handle: giftProduct.handle,
|
|
427
429
|
sku: giftProduct.sku
|
|
428
430
|
},
|