@moonbase.sh/vue 0.1.47 → 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 -2
- package/dist/index.js +6 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -253,8 +253,7 @@ function useCart() {
|
|
|
253
253
|
return { amount: total, currency };
|
|
254
254
|
}),
|
|
255
255
|
addToCart: (item, variation) => {
|
|
256
|
-
|
|
257
|
-
item = item.value;
|
|
256
|
+
item = (0, import_vue5.unref)(item);
|
|
258
257
|
variation != null ? variation : variation = item.defaultVariation;
|
|
259
258
|
if (!variation)
|
|
260
259
|
throw new Error("Added item does not have a default variation, and none have been specified");
|
|
@@ -289,6 +288,10 @@ function useCart() {
|
|
|
289
288
|
},
|
|
290
289
|
setQuantity: (cartItem, quantity) => {
|
|
291
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
|
+
}
|
|
292
295
|
const _ = storefront.pushOrderContent();
|
|
293
296
|
},
|
|
294
297
|
removeFromCart: (cartItem) => {
|
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,
|
|
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,8 +221,7 @@ function useCart() {
|
|
|
221
221
|
return { amount: total, currency };
|
|
222
222
|
}),
|
|
223
223
|
addToCart: (item, variation) => {
|
|
224
|
-
|
|
225
|
-
item = item.value;
|
|
224
|
+
item = unref(item);
|
|
226
225
|
variation != null ? variation : variation = item.defaultVariation;
|
|
227
226
|
if (!variation)
|
|
228
227
|
throw new Error("Added item does not have a default variation, and none have been specified");
|
|
@@ -257,6 +256,10 @@ function useCart() {
|
|
|
257
256
|
},
|
|
258
257
|
setQuantity: (cartItem, quantity) => {
|
|
259
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
|
+
}
|
|
260
263
|
const _ = storefront.pushOrderContent();
|
|
261
264
|
},
|
|
262
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",
|