@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/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var shopifySdk = require('@anker-in/shopify-sdk');
|
|
|
5
5
|
var Cookies5 = require('js-cookie');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var Decimal2 = require('decimal.js');
|
|
8
|
+
var shopifyCore = require('@anker-in/shopify-core');
|
|
8
9
|
var useSWR = require('swr');
|
|
9
10
|
var useSWRMutation = require('swr/mutation');
|
|
10
11
|
var ahooks = require('ahooks');
|
|
@@ -148,9 +149,10 @@ function normalizeAddToCartLines(lines) {
|
|
|
148
149
|
const variant = line.variant;
|
|
149
150
|
const product = variant.product;
|
|
150
151
|
const quantity = line.quantity || 1;
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
const
|
|
152
|
+
const originalPrice = variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : variant.price?.amount ? Number(variant.price.amount) : 0;
|
|
153
|
+
const finalPrice = variant.finalPrice?.amount ? Number(variant.finalPrice.amount) : originalPrice;
|
|
154
|
+
const subtotalAmount = originalPrice * quantity;
|
|
155
|
+
const totalAmount = finalPrice * quantity;
|
|
154
156
|
return {
|
|
155
157
|
id: `temp-line-${index}-${variant.id}`,
|
|
156
158
|
// Temporary ID for pre-cart lines
|
|
@@ -164,7 +166,7 @@ function normalizeAddToCartLines(lines) {
|
|
|
164
166
|
customAttributes: line.attributes || [],
|
|
165
167
|
variant: {
|
|
166
168
|
id: variant.id,
|
|
167
|
-
price,
|
|
169
|
+
price: variant.price?.amount ? Number(variant.price.amount) : 0,
|
|
168
170
|
listPrice: variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : 0,
|
|
169
171
|
sku: variant.sku || "",
|
|
170
172
|
name: variant.title || "",
|
|
@@ -241,7 +243,7 @@ var getMatchedMainProductSubTotal = (cartData, variant_list, main_product) => {
|
|
|
241
243
|
const matchedList = cartData?.lineItems?.filter((line) => {
|
|
242
244
|
const { is_gift } = getDiscountEnvAttributeValue(line.customAttributes);
|
|
243
245
|
return isAllStoreVariant ? !is_gift : variant_list?.find((item) => {
|
|
244
|
-
return !is_gift &&
|
|
246
|
+
return !is_gift && shopifyCore.atobID(line.variantId) === item;
|
|
245
247
|
});
|
|
246
248
|
});
|
|
247
249
|
return matchedList?.reduce((acc, line) => {
|
|
@@ -493,7 +495,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
493
495
|
if (!giftProduct) return null;
|
|
494
496
|
return {
|
|
495
497
|
variant: {
|
|
496
|
-
id:
|
|
498
|
+
id: shopifyCore.btoaID(giftProduct.variant_id),
|
|
497
499
|
handle: giftProduct.handle,
|
|
498
500
|
sku: giftProduct.sku
|
|
499
501
|
},
|