@moonbase.sh/vue 0.4.27 → 0.4.31
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/index.cjs +5 -3
- package/dist/index.js +5 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -365,13 +365,14 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
365
365
|
return this.currentUser.value;
|
|
366
366
|
}
|
|
367
367
|
async updateStorefront() {
|
|
368
|
+
var _a;
|
|
368
369
|
const latestStorefront = await this.client.storefront.get(this.hasUtm ? this.utm.value : void 0);
|
|
369
370
|
if (latestStorefront) {
|
|
370
371
|
if (typeof window !== "undefined")
|
|
371
372
|
localStorage.setItem(_StorefrontContextImpl.storefrontKey, JSON.stringify(latestStorefront));
|
|
372
373
|
this.storefront.value = latestStorefront;
|
|
373
374
|
this.loadedStorefront.value = true;
|
|
374
|
-
if (!this.currentOrder.value.currency || !latestStorefront.enabledCurrencies.includes(this.currentOrder.value.currency)) {
|
|
375
|
+
if (!this.currentOrder.value.currency || !((_a = latestStorefront.enabledCurrencies) == null ? void 0 : _a.includes(this.currentOrder.value.currency))) {
|
|
375
376
|
this.currentOrder.value.currency = latestStorefront.suggestedCurrency;
|
|
376
377
|
}
|
|
377
378
|
this.currentOrder.value.items = this.enrichLineItems(this.currentOrder.value.items);
|
|
@@ -413,6 +414,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
413
414
|
}
|
|
414
415
|
}
|
|
415
416
|
async refreshOrder() {
|
|
417
|
+
var _a;
|
|
416
418
|
try {
|
|
417
419
|
const latestOrder = await this.client.orders.get(this.currentOrder.value.id, { abort: this.refreshOrderAbortController.signal });
|
|
418
420
|
if (latestOrder) {
|
|
@@ -422,7 +424,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
422
424
|
latestOrder.items = this.enrichLineItems(latestOrder.items);
|
|
423
425
|
if (typeof window !== "undefined")
|
|
424
426
|
localStorage.setItem(_StorefrontContextImpl.sessionKey, JSON.stringify(latestOrder));
|
|
425
|
-
if (this.storefront.value && !this.storefront.value.enabledCurrencies.includes(latestOrder.currency)) {
|
|
427
|
+
if (this.storefront.value && !((_a = this.storefront.value.enabledCurrencies) == null ? void 0 : _a.includes(latestOrder.currency))) {
|
|
426
428
|
latestOrder.currency = this.storefront.value.suggestedCurrency;
|
|
427
429
|
}
|
|
428
430
|
this.currentOrder.value = latestOrder;
|
|
@@ -711,7 +713,7 @@ function useCart(context) {
|
|
|
711
713
|
const pickedVariation = variations.find((v) => v.id === item.variationId);
|
|
712
714
|
price = (_i = (_h = pickedVariation == null ? void 0 : pickedVariation.price[currency]) != null ? _h : (_g = bundle == null ? void 0 : bundle.defaultVariation) == null ? void 0 : _g.price[currency]) != null ? _i : 0;
|
|
713
715
|
}
|
|
714
|
-
const offer = (_j = storefront.storefront.value.offers) == null ? void 0 : _j.find((o) => o.id === item.offerId);
|
|
716
|
+
const offer = item.offerId ? (_j = storefront.storefront.value.offers) == null ? void 0 : _j.find((o) => o.id === item.offerId) : null;
|
|
715
717
|
if (offer && import_storefront_api4.OfferUtils.eligible(offer, storefront.currentOrder.value)) {
|
|
716
718
|
const offerDiscount = import_storefront_api4.DiscountUtils.apply(offer.discount, { [currency]: price });
|
|
717
719
|
price -= offerDiscount[currency];
|
package/dist/index.js
CHANGED
|
@@ -333,13 +333,14 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
333
333
|
return this.currentUser.value;
|
|
334
334
|
}
|
|
335
335
|
async updateStorefront() {
|
|
336
|
+
var _a;
|
|
336
337
|
const latestStorefront = await this.client.storefront.get(this.hasUtm ? this.utm.value : void 0);
|
|
337
338
|
if (latestStorefront) {
|
|
338
339
|
if (typeof window !== "undefined")
|
|
339
340
|
localStorage.setItem(_StorefrontContextImpl.storefrontKey, JSON.stringify(latestStorefront));
|
|
340
341
|
this.storefront.value = latestStorefront;
|
|
341
342
|
this.loadedStorefront.value = true;
|
|
342
|
-
if (!this.currentOrder.value.currency || !latestStorefront.enabledCurrencies.includes(this.currentOrder.value.currency)) {
|
|
343
|
+
if (!this.currentOrder.value.currency || !((_a = latestStorefront.enabledCurrencies) == null ? void 0 : _a.includes(this.currentOrder.value.currency))) {
|
|
343
344
|
this.currentOrder.value.currency = latestStorefront.suggestedCurrency;
|
|
344
345
|
}
|
|
345
346
|
this.currentOrder.value.items = this.enrichLineItems(this.currentOrder.value.items);
|
|
@@ -381,6 +382,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
384
|
async refreshOrder() {
|
|
385
|
+
var _a;
|
|
384
386
|
try {
|
|
385
387
|
const latestOrder = await this.client.orders.get(this.currentOrder.value.id, { abort: this.refreshOrderAbortController.signal });
|
|
386
388
|
if (latestOrder) {
|
|
@@ -390,7 +392,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
390
392
|
latestOrder.items = this.enrichLineItems(latestOrder.items);
|
|
391
393
|
if (typeof window !== "undefined")
|
|
392
394
|
localStorage.setItem(_StorefrontContextImpl.sessionKey, JSON.stringify(latestOrder));
|
|
393
|
-
if (this.storefront.value && !this.storefront.value.enabledCurrencies.includes(latestOrder.currency)) {
|
|
395
|
+
if (this.storefront.value && !((_a = this.storefront.value.enabledCurrencies) == null ? void 0 : _a.includes(latestOrder.currency))) {
|
|
394
396
|
latestOrder.currency = this.storefront.value.suggestedCurrency;
|
|
395
397
|
}
|
|
396
398
|
this.currentOrder.value = latestOrder;
|
|
@@ -679,7 +681,7 @@ function useCart(context) {
|
|
|
679
681
|
const pickedVariation = variations.find((v) => v.id === item.variationId);
|
|
680
682
|
price = (_i = (_h = pickedVariation == null ? void 0 : pickedVariation.price[currency]) != null ? _h : (_g = bundle == null ? void 0 : bundle.defaultVariation) == null ? void 0 : _g.price[currency]) != null ? _i : 0;
|
|
681
683
|
}
|
|
682
|
-
const offer = (_j = storefront.storefront.value.offers) == null ? void 0 : _j.find((o) => o.id === item.offerId);
|
|
684
|
+
const offer = item.offerId ? (_j = storefront.storefront.value.offers) == null ? void 0 : _j.find((o) => o.id === item.offerId) : null;
|
|
683
685
|
if (offer && OfferUtils2.eligible(offer, storefront.currentOrder.value)) {
|
|
684
686
|
const offerDiscount = DiscountUtils.apply(offer.discount, { [currency]: price });
|
|
685
687
|
price -= offerDiscount[currency];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.31",
|
|
5
5
|
"description": "Package to let you build vue.js storefronts with Moonbase.sh as payment and delivery provider",
|
|
6
6
|
"author": "Tobias Lønnerød Madsen <m@dsen.tv>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@vue/devtools-api": "^6.6.3",
|
|
20
20
|
"uuid": "^9.0.1",
|
|
21
21
|
"zod": "^3.23.8",
|
|
22
|
-
"@moonbase.sh/storefront-api": "0.4.
|
|
22
|
+
"@moonbase.sh/storefront-api": "0.4.31"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/uuid": "^9.0.8",
|