@zenky/storefront-vue 0.10.17 → 0.11.0
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/CHANGELOG.md +43 -0
- package/dist/cart/index.js +5 -5
- package/dist/chunk-544USTPB.js +45 -0
- package/dist/chunk-544USTPB.js.map +1 -0
- package/dist/{chunk-U5E6QSUO.js → chunk-5KCBZJV3.js} +45 -12
- package/dist/chunk-5KCBZJV3.js.map +1 -0
- package/dist/{chunk-F2LJ6TDH.js → chunk-KK645XNR.js} +169 -6
- package/dist/chunk-KK645XNR.js.map +1 -0
- package/dist/{chunk-LUJSF6V7.js → chunk-PBBVWWMI.js} +3 -3
- package/dist/{chunk-LUJSF6V7.js.map → chunk-PBBVWWMI.js.map} +1 -1
- package/dist/{chunk-L7UQIKDY.js → chunk-QFKA2R6D.js} +4 -4
- package/dist/{chunk-L7UQIKDY.js.map → chunk-QFKA2R6D.js.map} +1 -1
- package/dist/{chunk-54T72OLR.js → chunk-TXR76IDL.js} +107 -44
- package/dist/chunk-TXR76IDL.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/products/index.d.ts +41 -2
- package/dist/products/index.js +2 -2
- package/dist/promotions/index.js +3 -3
- package/dist/seo/index.js +3 -3
- package/dist/stores/index.d.ts +3 -2
- package/dist/stores/index.js +3 -3
- package/docs/consumer-setup.md +1 -1
- package/package.json +3 -3
- package/dist/chunk-54T72OLR.js.map +0 -1
- package/dist/chunk-F2LJ6TDH.js.map +0 -1
- package/dist/chunk-U5E6QSUO.js.map +0 -1
- package/dist/chunk-WTZXTBF6.js +0 -95
- package/dist/chunk-WTZXTBF6.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -184,6 +184,12 @@ All notable changes to this project are documented in this file. The format foll
|
|
|
184
184
|
a dispatch still in flight when the user resets their channel choice could resolve
|
|
185
185
|
afterward and resurrect the very channel they just backed out of (its success handler
|
|
186
186
|
writes `confirmationMethod` from the response, unconditionally).
|
|
187
|
+
- `useProductList.fetchProducts()` now sends `stock_id` (the customer's order's attached
|
|
188
|
+
stock, if any) or `city_id` as a fallback, never both, so category/collection listings
|
|
189
|
+
only show products with positive stock. Previously neither was sent. The stock read is
|
|
190
|
+
`cartStore.order?.stock?.id`, not `profileStore.stock` — the latter defaults to the
|
|
191
|
+
city's first configured stock even with no order at all (`getStock()` in
|
|
192
|
+
`catalogResolver.ts`), which would have made the `city_id` fallback effectively dead.
|
|
187
193
|
|
|
188
194
|
### Security
|
|
189
195
|
|
|
@@ -200,6 +206,43 @@ All notable changes to this project are documented in this file. The format foll
|
|
|
200
206
|
`register()` returning `true` left the user believing they were signed in when they
|
|
201
207
|
weren't. This path now performs a real `login()` with the same password instead.
|
|
202
208
|
|
|
209
|
+
## 0.11.0 - 2026-10-07
|
|
210
|
+
|
|
211
|
+
Needs `@zenky/storefront-api` `^1.7.0` (peer dependency).
|
|
212
|
+
|
|
213
|
+
### Added
|
|
214
|
+
|
|
215
|
+
- Order packaging: `ORDER_WITH` now includes `packages`, and `useCartStore` gets
|
|
216
|
+
`setOrderPackages(packages, packagingPrice)`. Add/remove responses don't carry
|
|
217
|
+
`packages`, so `useCartOperations` reloads them after the total is recalculated, but
|
|
218
|
+
only when the checkout total reports `packaging_price > 0`; at zero a leftover list is
|
|
219
|
+
cleared locally without a request. Late or out-of-order responses (an older sync, or a
|
|
220
|
+
previous order) are dropped, and a failed reload is logged without breaking the
|
|
221
|
+
add/remove. Needs `@zenky/storefront-api` with `Order.packages`,
|
|
222
|
+
`Order.packaging_price` and `OrderCheckoutTotal.packaging_price`.
|
|
223
|
+
- Merchant product badges (`/products`): `toProductBadgeViews` validates the backend
|
|
224
|
+
`Product.badges` list — drops badges with nothing to show, repeated ids and unusable
|
|
225
|
+
icons, accepts only hex colors (alpha is ignored) and http(s) image urls, and returns
|
|
226
|
+
`colors: null` when either color is missing or invalid so the consumer can fall back to
|
|
227
|
+
its theme. `getProductBadgeLayout` tells a text badge from an image without a label (drawn
|
|
228
|
+
as a square with no background), `filterProductBadges` hides either kind, and
|
|
229
|
+
`getProductBadgeAccent` derives a palette from the badge's own text/background pair
|
|
230
|
+
(accent, readable `on` color, hue-shifted gradient end, readable text, translucent glass
|
|
231
|
+
fill) with plain JS math, no CSS color functions. Styles, sizes and placement stay with
|
|
232
|
+
the consumer. Needs `@zenky/storefront-api` with `Product.badges` (`^1.6.0`).
|
|
233
|
+
|
|
234
|
+
### Changed
|
|
235
|
+
|
|
236
|
+
- `useCartStore.setOrder` keeps the previous `packages` (and `packaging_price`, unless the
|
|
237
|
+
new order brings its own) when the new order has the same id and no `packages`;
|
|
238
|
+
responses such as `setOrderPayments` omit them, and replacing the order wholesale made
|
|
239
|
+
the packaging block disappear while the total still included it.
|
|
240
|
+
- `addToCart` now forwards `promotionId` / `promotionRewardId` to the API as
|
|
241
|
+
`promotion_id` / `promotion_reward_id`, so promotion gifts are added through the regular
|
|
242
|
+
pipeline (total recalculation, packaging sync, promotion re-check) instead of a direct
|
|
243
|
+
SDK call. Gift adds do not emit add-to-cart analytics events (`productAddedToCart`,
|
|
244
|
+
`productQuantityIncreased`, `trackAddedToCart`); removal events are unchanged.
|
|
245
|
+
|
|
203
246
|
## 0.10.7 - 2026-08-02
|
|
204
247
|
|
|
205
248
|
### Added
|
package/dist/cart/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from '../chunk-
|
|
2
|
-
export { useCartCredentials } from '../chunk-L7UQIKDY.js';
|
|
1
|
+
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from '../chunk-5KCBZJV3.js';
|
|
3
2
|
import '../chunk-5QCUH3FF.js';
|
|
4
3
|
export { getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getValidationErrors, logCartError } from '../chunk-TE42OCFK.js';
|
|
5
|
-
import '../chunk-54T72OLR.js';
|
|
6
4
|
import '../chunk-4JCJHAL3.js';
|
|
7
|
-
import '../chunk-WTZXTBF6.js';
|
|
8
5
|
import '../chunk-TIQ7AJLY.js';
|
|
9
|
-
import '../chunk-IOYYCA75.js';
|
|
10
6
|
import '../chunk-FS2UNPTY.js';
|
|
11
7
|
import '../chunk-2Y6QTHXI.js';
|
|
8
|
+
export { useCartCredentials } from '../chunk-QFKA2R6D.js';
|
|
9
|
+
import '../chunk-544USTPB.js';
|
|
10
|
+
import '../chunk-TXR76IDL.js';
|
|
11
|
+
import '../chunk-IOYYCA75.js';
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { ref, computed } from 'vue';
|
|
3
|
+
|
|
4
|
+
// src/stores/promotions.ts
|
|
5
|
+
var usePromotionsStore = defineStore("zenky-promotions", () => {
|
|
6
|
+
const rewards = ref([]);
|
|
7
|
+
const checking = ref(false);
|
|
8
|
+
function addOrUpdateReward(selection) {
|
|
9
|
+
const index = rewards.value.findIndex((r) => r.promotionId === selection.promotionId);
|
|
10
|
+
if (index >= 0) {
|
|
11
|
+
rewards.value[index] = selection;
|
|
12
|
+
} else {
|
|
13
|
+
rewards.value.push(selection);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function removeRewardByPromotion(promotionId) {
|
|
17
|
+
rewards.value = rewards.value.filter((r) => r.promotionId !== promotionId);
|
|
18
|
+
}
|
|
19
|
+
function clearRewards() {
|
|
20
|
+
rewards.value = [];
|
|
21
|
+
}
|
|
22
|
+
function setChecking(value) {
|
|
23
|
+
checking.value = value;
|
|
24
|
+
}
|
|
25
|
+
const hasRewards = computed(() => rewards.value.length > 0);
|
|
26
|
+
const totalEmptySlots = computed(() => rewards.value.reduce((sum, r) => sum + r.limit, 0));
|
|
27
|
+
const rewardSelection = computed(() => rewards.value[0] ?? null);
|
|
28
|
+
const needsSelection = computed(() => rewards.value.some((r) => r.context !== null));
|
|
29
|
+
return {
|
|
30
|
+
rewards,
|
|
31
|
+
checking,
|
|
32
|
+
addOrUpdateReward,
|
|
33
|
+
removeRewardByPromotion,
|
|
34
|
+
clearRewards,
|
|
35
|
+
setChecking,
|
|
36
|
+
hasRewards,
|
|
37
|
+
totalEmptySlots,
|
|
38
|
+
rewardSelection,
|
|
39
|
+
needsSelection
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export { usePromotionsStore };
|
|
44
|
+
//# sourceMappingURL=chunk-544USTPB.js.map
|
|
45
|
+
//# sourceMappingURL=chunk-544USTPB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stores/promotions.ts"],"names":[],"mappings":";;;;AA6BO,IAAM,kBAAA,GAAqB,WAAA,CAAY,kBAAA,EAAoB,MAAuB;AAErF,EAAA,MAAM,OAAA,GAAU,GAAA,CAAuB,EAAE,CAAA;AACzC,EAAA,MAAM,QAAA,GAAW,IAAI,KAAK,CAAA;AAE1B,EAAA,SAAS,kBAAkB,SAAA,EAAkC;AACzD,IAAA,MAAM,KAAA,GAAQ,QAAQ,KAAA,CAAM,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,WAAA,KAAgB,SAAA,CAAU,WAAW,CAAA;AACpF,IAAA,IAAI,SAAS,CAAA,EAAG;AACZ,MAAA,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA,GAAI,SAAA;AAAA,IAC3B,CAAA,MAAO;AACH,MAAA,OAAA,CAAQ,KAAA,CAAM,KAAK,SAAS,CAAA;AAAA,IAChC;AAAA,EACJ;AAEA,EAAA,SAAS,wBAAwB,WAAA,EAA2B;AACxD,IAAA,OAAA,CAAQ,KAAA,GAAQ,QAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,gBAAgB,WAAW,CAAA;AAAA,EAC7E;AAEA,EAAA,SAAS,YAAA,GAAqB;AAC1B,IAAA,OAAA,CAAQ,QAAQ,EAAC;AAAA,EACrB;AAEA,EAAA,SAAS,YAAY,KAAA,EAAsB;AACvC,IAAA,QAAA,CAAS,KAAA,GAAQ,KAAA;AAAA,EACrB;AAEA,EAAA,MAAM,aAAa,QAAA,CAAS,MAAM,OAAA,CAAQ,KAAA,CAAM,SAAS,CAAC,CAAA;AAC1D,EAAA,MAAM,eAAA,GAAkB,QAAA,CAAS,MAAM,OAAA,CAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,GAAA,EAAK,CAAA,KAAM,GAAA,GAAM,CAAA,CAAE,KAAA,EAAO,CAAC,CAAC,CAAA;AAEzF,EAAA,MAAM,kBAAkB,QAAA,CAAiC,MAAM,QAAQ,KAAA,CAAM,CAAC,KAAK,IAAI,CAAA;AACvF,EAAA,MAAM,cAAA,GAAiB,QAAA,CAAS,MAAM,OAAA,CAAQ,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAA,KAAY,IAAI,CAAC,CAAA;AAEnF,EAAA,OAAO;AAAA,IACH,OAAA;AAAA,IACA,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,uBAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA;AAAA,IACA,eAAA;AAAA,IACA,eAAA;AAAA,IACA;AAAA,GACJ;AACJ,CAAC","file":"chunk-544USTPB.js","sourcesContent":["import { defineStore } from 'pinia'\nimport { computed, ref, type ComputedRef, type Ref } from 'vue'\n\nexport interface RewardSelectionContext {\n type: string\n id: string\n}\n\nexport interface RewardSelection {\n offerId: string\n promotionId: string\n rewardId: string\n context: RewardSelectionContext | null\n limit: number\n}\n\nexport interface PromotionsStore {\n rewards: Ref<RewardSelection[]>\n checking: Ref<boolean>\n addOrUpdateReward: (selection: RewardSelection) => void\n removeRewardByPromotion: (promotionId: string) => void\n clearRewards: () => void\n setChecking: (value: boolean) => void\n hasRewards: ComputedRef<boolean>\n totalEmptySlots: ComputedRef<number>\n rewardSelection: ComputedRef<RewardSelection | null>\n needsSelection: ComputedRef<boolean>\n}\n\nexport const usePromotionsStore = defineStore('zenky-promotions', (): PromotionsStore => {\n /** Available rewards (multiple promotions can be active at the same time). */\n const rewards = ref<RewardSelection[]>([])\n const checking = ref(false)\n\n function addOrUpdateReward(selection: RewardSelection): void {\n const index = rewards.value.findIndex((r) => r.promotionId === selection.promotionId)\n if (index >= 0) {\n rewards.value[index] = selection\n } else {\n rewards.value.push(selection)\n }\n }\n\n function removeRewardByPromotion(promotionId: string): void {\n rewards.value = rewards.value.filter((r) => r.promotionId !== promotionId)\n }\n\n function clearRewards(): void {\n rewards.value = []\n }\n\n function setChecking(value: boolean): void {\n checking.value = value\n }\n\n const hasRewards = computed(() => rewards.value.length > 0)\n const totalEmptySlots = computed(() => rewards.value.reduce((sum, r) => sum + r.limit, 0))\n /** Kept for backward compatibility — the first reward. */\n const rewardSelection = computed<RewardSelection | null>(() => rewards.value[0] ?? null)\n const needsSelection = computed(() => rewards.value.some((r) => r.context !== null))\n\n return {\n rewards,\n checking,\n addOrUpdateReward,\n removeRewardByPromotion,\n clearRewards,\n setChecking,\n hasRewards,\n totalEmptySlots,\n rewardSelection,\n needsSelection,\n }\n})\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useCartCredentials, usePromotionsChecker } from './chunk-L7UQIKDY.js';
|
|
2
1
|
import { createRuntimeState } from './chunk-5QCUH3FF.js';
|
|
3
2
|
import { logCartError, getCartErrorHttpCode, getCartErrorCode, getCartErrorMessage } from './chunk-TE42OCFK.js';
|
|
4
|
-
import { useCartStore, useOrderSettingsStore, usePromotionsStore } from './chunk-54T72OLR.js';
|
|
5
3
|
import { useCatalogStore } from './chunk-4JCJHAL3.js';
|
|
6
|
-
import { useRuntime, useAuthStore } from './chunk-WTZXTBF6.js';
|
|
7
4
|
import { toRequestedMethod } from './chunk-TIQ7AJLY.js';
|
|
8
|
-
import { useStoreProfileStore } from './chunk-IOYYCA75.js';
|
|
9
5
|
import { getRemoteCatalog } from './chunk-FS2UNPTY.js';
|
|
10
6
|
import { minorToMajor, majorToMinor } from './chunk-2Y6QTHXI.js';
|
|
7
|
+
import { useCartCredentials, usePromotionsChecker } from './chunk-QFKA2R6D.js';
|
|
8
|
+
import { usePromotionsStore } from './chunk-544USTPB.js';
|
|
9
|
+
import { useRuntime, useCartStore, useAuthStore, useOrderSettingsStore } from './chunk-TXR76IDL.js';
|
|
10
|
+
import { useStoreProfileStore } from './chunk-IOYYCA75.js';
|
|
11
11
|
import { PaymentMethod, OrderAuthenticationMethod, DeliveryMethod, OrderCartCheckerResultAction, RecaptchaAction } from '@zenky/storefront-api';
|
|
12
12
|
import { ref, computed, watch, watchEffect, getCurrentScope, onScopeDispose, toValue } from 'vue';
|
|
13
13
|
import { storeToRefs } from 'pinia';
|
|
@@ -340,6 +340,7 @@ var ORDER_INCLUDES = [
|
|
|
340
340
|
"payments",
|
|
341
341
|
"progress",
|
|
342
342
|
"promocode",
|
|
343
|
+
"packages",
|
|
343
344
|
"variants.variant.options",
|
|
344
345
|
"variants.product.images",
|
|
345
346
|
"variants.product.categories",
|
|
@@ -1339,17 +1340,43 @@ var BATCH_DELAY = 250;
|
|
|
1339
1340
|
var CART_LINE_KIND_PREFIX = "cart-line-";
|
|
1340
1341
|
var getOperationsState = createRuntimeState(() => ({
|
|
1341
1342
|
batches: /* @__PURE__ */ new Map(),
|
|
1342
|
-
inflight: /* @__PURE__ */ new Set()
|
|
1343
|
+
inflight: /* @__PURE__ */ new Set(),
|
|
1344
|
+
packagesSeq: 0
|
|
1343
1345
|
}));
|
|
1344
1346
|
function useCartOperations(credentials, initialization, sdk, deps) {
|
|
1345
1347
|
const { notifier, activity } = deps;
|
|
1346
1348
|
const runtime = useRuntime();
|
|
1347
1349
|
const { events, rum, commerceEvents, messages } = runtime;
|
|
1348
|
-
const
|
|
1350
|
+
const state = getOperationsState(runtime);
|
|
1351
|
+
const { batches, inflight } = state;
|
|
1349
1352
|
const cartStore = useCartStore();
|
|
1350
1353
|
const profileStore = useStoreProfileStore();
|
|
1351
1354
|
const { run: runMutation, bumpKindsWithPrefix } = useCartMutation();
|
|
1352
1355
|
const { recalculateAfterOrderChange } = useCartRecalculation({ notifier, activity });
|
|
1356
|
+
async function syncPackages(isStale) {
|
|
1357
|
+
const mySeq = ++state.packagesSeq;
|
|
1358
|
+
const packagingPrice = cartStore.checkoutTotal?.packaging_price ?? 0;
|
|
1359
|
+
const hasPackages = (cartStore.order?.packages?.length ?? 0) > 0;
|
|
1360
|
+
if (packagingPrice <= 0) {
|
|
1361
|
+
if (hasPackages && !isStale()) cartStore.setOrderPackages([], 0);
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
try {
|
|
1365
|
+
const fresh = await sdk.orders.getOrder(
|
|
1366
|
+
credentials.getStoreId(),
|
|
1367
|
+
credentials.getCredentials(),
|
|
1368
|
+
{ with: "packages" }
|
|
1369
|
+
);
|
|
1370
|
+
if (isStale() || mySeq !== state.packagesSeq) return;
|
|
1371
|
+
if (fresh.id !== cartStore.order?.id) return;
|
|
1372
|
+
cartStore.setOrderPackages(fresh.packages ?? [], fresh.packaging_price ?? null);
|
|
1373
|
+
} catch (e) {
|
|
1374
|
+
logCartError(
|
|
1375
|
+
{ scope: "cart-packages", context: { orderId: cartStore.credentials?.id } },
|
|
1376
|
+
e
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1353
1380
|
function flushBatch(lineKey) {
|
|
1354
1381
|
if (inflight.has(lineKey)) return;
|
|
1355
1382
|
const batch = batches.get(lineKey);
|
|
@@ -1362,6 +1389,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1362
1389
|
inflight.add(lineKey);
|
|
1363
1390
|
const sentDelta = batch.delta;
|
|
1364
1391
|
const isAdd = sentDelta > 0;
|
|
1392
|
+
const isPromotionLine = Boolean(batch.promotionId);
|
|
1365
1393
|
const qty = Math.abs(sentDelta);
|
|
1366
1394
|
const { variantId, productId, productName, variantLabel } = batch;
|
|
1367
1395
|
const execute = async () => {
|
|
@@ -1382,6 +1410,10 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1382
1410
|
product_variant_id: variantId,
|
|
1383
1411
|
quantity: qty,
|
|
1384
1412
|
modifiers: batch.modifiers,
|
|
1413
|
+
...batch.promotionId ? {
|
|
1414
|
+
promotion_id: batch.promotionId,
|
|
1415
|
+
promotion_reward_id: batch.promotionRewardId
|
|
1416
|
+
} : {},
|
|
1385
1417
|
...batch.recommendationsBlock ? { recommendations_block: batch.recommendationsBlock } : {}
|
|
1386
1418
|
}
|
|
1387
1419
|
);
|
|
@@ -1414,7 +1446,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1414
1446
|
optimisticCorrected = true;
|
|
1415
1447
|
const integrations = events?.get() ?? null;
|
|
1416
1448
|
const orderVariant = cartStore.order?.variants?.find((v) => variantLineKey(v) === lineKey) ?? null;
|
|
1417
|
-
if (isAdd) {
|
|
1449
|
+
if (isAdd && !isPromotionLine) {
|
|
1418
1450
|
if (!wasInCartBefore) {
|
|
1419
1451
|
integrations?.productAddedToCart({
|
|
1420
1452
|
order: cartStore.order,
|
|
@@ -1426,7 +1458,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1426
1458
|
orderVariant
|
|
1427
1459
|
});
|
|
1428
1460
|
}
|
|
1429
|
-
} else {
|
|
1461
|
+
} else if (!isAdd) {
|
|
1430
1462
|
const isNowInCart = cartStore.order?.variants?.some((v) => variantLineKey(v) === lineKey) ?? false;
|
|
1431
1463
|
if (!isNowInCart) {
|
|
1432
1464
|
const product = variantBeforeChange?.product ?? null;
|
|
@@ -1443,7 +1475,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1443
1475
|
}
|
|
1444
1476
|
const commerceOrderId = cartStore.credentials?.id;
|
|
1445
1477
|
if (commerceOrderId && commerceEvents) {
|
|
1446
|
-
if (isAdd) {
|
|
1478
|
+
if (isAdd && !isPromotionLine) {
|
|
1447
1479
|
const currency = profileStore.currency;
|
|
1448
1480
|
const cartTotal = cartStore.order?.total_price;
|
|
1449
1481
|
commerceEvents.trackAddedToCart(commerceOrderId, {
|
|
@@ -1454,7 +1486,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1454
1486
|
totalPrice: cartTotal != null ? minorToMajor(cartTotal, currency) : void 0,
|
|
1455
1487
|
recommendationsBlock: batch.recommendationsBlock
|
|
1456
1488
|
});
|
|
1457
|
-
} else {
|
|
1489
|
+
} else if (!isAdd) {
|
|
1458
1490
|
commerceEvents.trackRemovedFromCart(commerceOrderId, {
|
|
1459
1491
|
productId,
|
|
1460
1492
|
productVariantId: variantId,
|
|
@@ -1463,6 +1495,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1463
1495
|
}
|
|
1464
1496
|
}
|
|
1465
1497
|
await recalculateAfterOrderChange();
|
|
1498
|
+
await syncPackages(isStale);
|
|
1466
1499
|
if (isAdd && productName) {
|
|
1467
1500
|
const parts = [productName, variantLabel].filter(Boolean);
|
|
1468
1501
|
notifier.message(messages.format("cart.added.title"), {
|
|
@@ -1950,5 +1983,5 @@ function useVisibleCartVariants() {
|
|
|
1950
1983
|
}
|
|
1951
1984
|
|
|
1952
1985
|
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey };
|
|
1953
|
-
//# sourceMappingURL=chunk-
|
|
1954
|
-
//# sourceMappingURL=chunk-
|
|
1986
|
+
//# sourceMappingURL=chunk-5KCBZJV3.js.map
|
|
1987
|
+
//# sourceMappingURL=chunk-5KCBZJV3.js.map
|