@moonbase.sh/vue 0.4.31 → 0.4.32
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 +20 -3
- package/dist/index.js +20 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -792,13 +792,15 @@ function useCart(context) {
|
|
|
792
792
|
}
|
|
793
793
|
function addReplacedBundleProducts(cartItem) {
|
|
794
794
|
var _a, _b;
|
|
795
|
+
if (!storefront)
|
|
796
|
+
return;
|
|
795
797
|
if (cartItem.type === "Bundle" && cartItem.replaced && cartItem.replaced.length > 0) {
|
|
796
798
|
for (const { productId, variationId } of cartItem.replaced.map((composite) => ({ productId: composite.split("/")[0], variationId: composite.split("/")[1] }))) {
|
|
797
|
-
const product = storefront
|
|
799
|
+
const product = storefront.storefront.value.products.find((p) => p.id === productId);
|
|
798
800
|
const variation = (_a = product == null ? void 0 : product.variations) == null ? void 0 : _a.find((v) => v.id === variationId);
|
|
799
|
-
if (product && variation && !
|
|
801
|
+
if (product && variation && !storefront.currentOrder.value.items.some((i) => i.type === "Product" && i.productId === productId)) {
|
|
800
802
|
const id = `p/${product.id}/${variationId}`;
|
|
801
|
-
storefront
|
|
803
|
+
storefront.currentOrder.value.items.push({
|
|
802
804
|
id,
|
|
803
805
|
type: "Product",
|
|
804
806
|
productId: product.id,
|
|
@@ -815,6 +817,19 @@ function useCart(context) {
|
|
|
815
817
|
}
|
|
816
818
|
}
|
|
817
819
|
}
|
|
820
|
+
function pruneIneligibleOffers() {
|
|
821
|
+
var _a;
|
|
822
|
+
if (!storefront)
|
|
823
|
+
return;
|
|
824
|
+
for (const item of storefront.currentOrder.value.items) {
|
|
825
|
+
if (item.offerId) {
|
|
826
|
+
const offer = (_a = storefront.storefront.value.offers) == null ? void 0 : _a.find((o) => o.id === item.offerId);
|
|
827
|
+
if (!offer || !import_storefront_api4.OfferUtils.eligible(offer, storefront.currentOrder.value)) {
|
|
828
|
+
item.offerId = void 0;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
818
833
|
return {
|
|
819
834
|
items: (0, import_vue6.computed)(() => storefront.enrichLineItems(storefront.currentOrder.value.items)),
|
|
820
835
|
currency: (0, import_vue6.computed)(() => storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency),
|
|
@@ -829,6 +844,7 @@ function useCart(context) {
|
|
|
829
844
|
const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItemRef.id);
|
|
830
845
|
storefront.currentOrder.value.items.splice(index, 1);
|
|
831
846
|
addReplacedBundleProducts(cartItem);
|
|
847
|
+
pruneIneligibleOffers();
|
|
832
848
|
}
|
|
833
849
|
const _ = storefront.pushOrderContent();
|
|
834
850
|
return cartItem;
|
|
@@ -837,6 +853,7 @@ function useCart(context) {
|
|
|
837
853
|
const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItem.id);
|
|
838
854
|
storefront.currentOrder.value.items.splice(index, 1);
|
|
839
855
|
addReplacedBundleProducts(cartItem);
|
|
856
|
+
pruneIneligibleOffers();
|
|
840
857
|
const _ = storefront.pushOrderContent();
|
|
841
858
|
},
|
|
842
859
|
checkout: async (options) => {
|
package/dist/index.js
CHANGED
|
@@ -760,13 +760,15 @@ function useCart(context) {
|
|
|
760
760
|
}
|
|
761
761
|
function addReplacedBundleProducts(cartItem) {
|
|
762
762
|
var _a, _b;
|
|
763
|
+
if (!storefront)
|
|
764
|
+
return;
|
|
763
765
|
if (cartItem.type === "Bundle" && cartItem.replaced && cartItem.replaced.length > 0) {
|
|
764
766
|
for (const { productId, variationId } of cartItem.replaced.map((composite) => ({ productId: composite.split("/")[0], variationId: composite.split("/")[1] }))) {
|
|
765
|
-
const product = storefront
|
|
767
|
+
const product = storefront.storefront.value.products.find((p) => p.id === productId);
|
|
766
768
|
const variation = (_a = product == null ? void 0 : product.variations) == null ? void 0 : _a.find((v) => v.id === variationId);
|
|
767
|
-
if (product && variation && !
|
|
769
|
+
if (product && variation && !storefront.currentOrder.value.items.some((i) => i.type === "Product" && i.productId === productId)) {
|
|
768
770
|
const id = `p/${product.id}/${variationId}`;
|
|
769
|
-
storefront
|
|
771
|
+
storefront.currentOrder.value.items.push({
|
|
770
772
|
id,
|
|
771
773
|
type: "Product",
|
|
772
774
|
productId: product.id,
|
|
@@ -783,6 +785,19 @@ function useCart(context) {
|
|
|
783
785
|
}
|
|
784
786
|
}
|
|
785
787
|
}
|
|
788
|
+
function pruneIneligibleOffers() {
|
|
789
|
+
var _a;
|
|
790
|
+
if (!storefront)
|
|
791
|
+
return;
|
|
792
|
+
for (const item of storefront.currentOrder.value.items) {
|
|
793
|
+
if (item.offerId) {
|
|
794
|
+
const offer = (_a = storefront.storefront.value.offers) == null ? void 0 : _a.find((o) => o.id === item.offerId);
|
|
795
|
+
if (!offer || !OfferUtils2.eligible(offer, storefront.currentOrder.value)) {
|
|
796
|
+
item.offerId = void 0;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
786
801
|
return {
|
|
787
802
|
items: computed4(() => storefront.enrichLineItems(storefront.currentOrder.value.items)),
|
|
788
803
|
currency: computed4(() => storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency),
|
|
@@ -797,6 +812,7 @@ function useCart(context) {
|
|
|
797
812
|
const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItemRef.id);
|
|
798
813
|
storefront.currentOrder.value.items.splice(index, 1);
|
|
799
814
|
addReplacedBundleProducts(cartItem);
|
|
815
|
+
pruneIneligibleOffers();
|
|
800
816
|
}
|
|
801
817
|
const _ = storefront.pushOrderContent();
|
|
802
818
|
return cartItem;
|
|
@@ -805,6 +821,7 @@ function useCart(context) {
|
|
|
805
821
|
const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItem.id);
|
|
806
822
|
storefront.currentOrder.value.items.splice(index, 1);
|
|
807
823
|
addReplacedBundleProducts(cartItem);
|
|
824
|
+
pruneIneligibleOffers();
|
|
808
825
|
const _ = storefront.pushOrderContent();
|
|
809
826
|
},
|
|
810
827
|
checkout: async (options) => {
|
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.32",
|
|
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.32"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/uuid": "^9.0.8",
|