@moonbase.sh/vue 0.1.46 → 0.1.48
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 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -253,6 +253,7 @@ function useCart() {
|
|
|
253
253
|
return { amount: total, currency };
|
|
254
254
|
}),
|
|
255
255
|
addToCart: (item, variation) => {
|
|
256
|
+
item = (0, import_vue5.unref)(item);
|
|
256
257
|
variation != null ? variation : variation = item.defaultVariation;
|
|
257
258
|
if (!variation)
|
|
258
259
|
throw new Error("Added item does not have a default variation, and none have been specified");
|
|
@@ -287,6 +288,10 @@ function useCart() {
|
|
|
287
288
|
},
|
|
288
289
|
setQuantity: (cartItem, quantity) => {
|
|
289
290
|
cartItem.quantity = quantity;
|
|
291
|
+
if (cartItem.quantity <= 0) {
|
|
292
|
+
const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItem.id);
|
|
293
|
+
storefront.currentOrder.value.items.splice(index, 1);
|
|
294
|
+
}
|
|
290
295
|
const _ = storefront.pushOrderContent();
|
|
291
296
|
},
|
|
292
297
|
removeFromCart: (cartItem) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -39,7 +39,7 @@ declare function useCart(): {
|
|
|
39
39
|
amount: number;
|
|
40
40
|
currency: string;
|
|
41
41
|
}>;
|
|
42
|
-
addToCart: (item: StorefrontProduct | StorefrontBundle
|
|
42
|
+
addToCart: (item: StorefrontProduct | StorefrontBundle | Ref<StorefrontProduct> | Ref<StorefrontBundle>, variation?: PricingVariation) => void;
|
|
43
43
|
setQuantity: (cartItem: CartItem, quantity: number) => void;
|
|
44
44
|
removeFromCart: (cartItem: CartItem) => void;
|
|
45
45
|
checkout: (returnUrl: string) => Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ declare function useCart(): {
|
|
|
39
39
|
amount: number;
|
|
40
40
|
currency: string;
|
|
41
41
|
}>;
|
|
42
|
-
addToCart: (item: StorefrontProduct | StorefrontBundle
|
|
42
|
+
addToCart: (item: StorefrontProduct | StorefrontBundle | Ref<StorefrontProduct> | Ref<StorefrontBundle>, variation?: PricingVariation) => void;
|
|
43
43
|
setQuantity: (cartItem: CartItem, quantity: number) => void;
|
|
44
44
|
removeFromCart: (cartItem: CartItem) => void;
|
|
45
45
|
checkout: (returnUrl: string) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -192,7 +192,7 @@ function useProducts() {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// src/composables/useCart.ts
|
|
195
|
-
import { computed as computed5, inject as inject5 } from "vue";
|
|
195
|
+
import { computed as computed5, inject as inject5, unref } from "vue";
|
|
196
196
|
function useCart() {
|
|
197
197
|
const storefront = inject5(storefrontKey);
|
|
198
198
|
if (!storefront)
|
|
@@ -221,6 +221,7 @@ function useCart() {
|
|
|
221
221
|
return { amount: total, currency };
|
|
222
222
|
}),
|
|
223
223
|
addToCart: (item, variation) => {
|
|
224
|
+
item = unref(item);
|
|
224
225
|
variation != null ? variation : variation = item.defaultVariation;
|
|
225
226
|
if (!variation)
|
|
226
227
|
throw new Error("Added item does not have a default variation, and none have been specified");
|
|
@@ -255,6 +256,10 @@ function useCart() {
|
|
|
255
256
|
},
|
|
256
257
|
setQuantity: (cartItem, quantity) => {
|
|
257
258
|
cartItem.quantity = quantity;
|
|
259
|
+
if (cartItem.quantity <= 0) {
|
|
260
|
+
const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItem.id);
|
|
261
|
+
storefront.currentOrder.value.items.splice(index, 1);
|
|
262
|
+
}
|
|
258
263
|
const _ = storefront.pushOrderContent();
|
|
259
264
|
},
|
|
260
265
|
removeFromCart: (cartItem) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.48",
|
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@vue/devtools-api": "^6.5.1",
|
|
20
20
|
"uuid": "^9.0.1",
|
|
21
|
-
"@moonbase.sh/api-client": "0.1.
|
|
21
|
+
"@moonbase.sh/api-client": "0.1.48"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/uuid": "^9.0.7",
|