@anker-in/shopify-react 0.1.1-beta.21 → 0.1.1-beta.23
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.d.mts +245 -210
- package/dist/hooks/index.d.ts +245 -210
- package/dist/hooks/index.js +72 -9
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +71 -8
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +72 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -8
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +1 -2
- package/dist/provider/index.d.ts +1 -2
- package/dist/provider/index.js +9 -7
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +8 -6
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-C1So3siD.d.mts → types-BSsb8OPm.d.mts} +1 -34
- package/dist/{types-C1So3siD.d.ts → types-BSsb8OPm.d.ts} +1 -34
- package/package.json +3 -3
|
@@ -4,8 +4,7 @@ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, Attrib
|
|
|
4
4
|
import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter } from '../types-Dt0DUG00.mjs';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { SWRConfiguration } from 'swr';
|
|
7
|
-
import { e as PlusMemberSettingsMetafields } from '../types-
|
|
8
|
-
import 'swr/mutation';
|
|
7
|
+
import { e as PlusMemberSettingsMetafields } from '../types-BSsb8OPm.mjs';
|
|
9
8
|
|
|
10
9
|
interface ShopifyContextValue {
|
|
11
10
|
client: ShopifyClient;
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, Attrib
|
|
|
4
4
|
import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter } from '../types-Dt0DUG00.js';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { SWRConfiguration } from 'swr';
|
|
7
|
-
import { e as PlusMemberSettingsMetafields } from '../types-
|
|
8
|
-
import 'swr/mutation';
|
|
7
|
+
import { e as PlusMemberSettingsMetafields } from '../types-BSsb8OPm.js';
|
|
9
8
|
|
|
10
9
|
interface ShopifyContextValue {
|
|
11
10
|
client: ShopifyClient;
|
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
|
},
|
|
@@ -929,7 +931,7 @@ var useUpdateLineCodeAmountAttributes = ({
|
|
|
929
931
|
);
|
|
930
932
|
const functionEnvValue = getDiscountEnvAttributeValue(line.customAttributes);
|
|
931
933
|
const hasSameFunctionEnvAttribute = Number(functionEnvValue.discounted_amount) === Number(line.totalAmount);
|
|
932
|
-
if (!hasSameFunctionEnvAttribute && hasFunctionEnvAttribute) {
|
|
934
|
+
if (!hasSameFunctionEnvAttribute && hasFunctionEnvAttribute && !functionEnvValue.is_gift) {
|
|
933
935
|
attrNeedUpdate.push({
|
|
934
936
|
key: CUSTOMER_ATTRIBUTE_KEY,
|
|
935
937
|
value: JSON.stringify({
|