@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/provider/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 useSWRMutation8 = require('swr/mutation');
|
|
10
11
|
var ahooks = require('ahooks');
|
|
@@ -110,9 +111,10 @@ function normalizeAddToCartLines(lines) {
|
|
|
110
111
|
const variant = line.variant;
|
|
111
112
|
const product = variant.product;
|
|
112
113
|
const quantity = line.quantity || 1;
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const
|
|
114
|
+
const originalPrice = variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : variant.price?.amount ? Number(variant.price.amount) : 0;
|
|
115
|
+
const finalPrice = variant.finalPrice?.amount ? Number(variant.finalPrice.amount) : originalPrice;
|
|
116
|
+
const subtotalAmount = originalPrice * quantity;
|
|
117
|
+
const totalAmount = finalPrice * quantity;
|
|
116
118
|
return {
|
|
117
119
|
id: `temp-line-${index}-${variant.id}`,
|
|
118
120
|
// Temporary ID for pre-cart lines
|
|
@@ -126,7 +128,7 @@ function normalizeAddToCartLines(lines) {
|
|
|
126
128
|
customAttributes: line.attributes || [],
|
|
127
129
|
variant: {
|
|
128
130
|
id: variant.id,
|
|
129
|
-
price,
|
|
131
|
+
price: variant.price?.amount ? Number(variant.price.amount) : 0,
|
|
130
132
|
listPrice: variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : 0,
|
|
131
133
|
sku: variant.sku || "",
|
|
132
134
|
name: variant.title || "",
|
|
@@ -203,7 +205,7 @@ var getMatchedMainProductSubTotal = (cartData, variant_list, main_product) => {
|
|
|
203
205
|
const matchedList = cartData?.lineItems?.filter((line) => {
|
|
204
206
|
const { is_gift } = getDiscountEnvAttributeValue(line.customAttributes);
|
|
205
207
|
return isAllStoreVariant ? !is_gift : variant_list?.find((item) => {
|
|
206
|
-
return !is_gift &&
|
|
208
|
+
return !is_gift && shopifyCore.atobID(line.variantId) === item;
|
|
207
209
|
});
|
|
208
210
|
});
|
|
209
211
|
return matchedList?.reduce((acc, line) => {
|
|
@@ -452,7 +454,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
452
454
|
if (!giftProduct) return null;
|
|
453
455
|
return {
|
|
454
456
|
variant: {
|
|
455
|
-
id:
|
|
457
|
+
id: shopifyCore.btoaID(giftProduct.variant_id),
|
|
456
458
|
handle: giftProduct.handle,
|
|
457
459
|
sku: giftProduct.sku
|
|
458
460
|
},
|