@moonbase.sh/vue 0.1.43 → 0.1.45

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 CHANGED
@@ -256,10 +256,12 @@ function useCart() {
256
256
  variation != null ? variation : variation = item.defaultVariation;
257
257
  if (!variation)
258
258
  throw new Error("Added item does not have a default variation, and none have been specified");
259
- let lineItem = storefront.currentOrder.value.items.find((i) => i.type === "Product" && i.productId === item.id && i.variationId === variation.id || i.type === "Bundle" && i.bundleId === item.id && i.variationId === variation.id);
259
+ const id = `b/${item.id}/${variation.id}`;
260
+ let lineItem = storefront.currentOrder.value.items.find((i) => i.id === id);
260
261
  if (!lineItem) {
261
262
  if (item.type === "bundle") {
262
263
  lineItem = {
264
+ id,
263
265
  type: "Bundle",
264
266
  bundleId: item.id,
265
267
  bundle: item,
@@ -269,6 +271,7 @@ function useCart() {
269
271
  storefront.currentOrder.value.items.push(lineItem);
270
272
  } else if (item.type === "product") {
271
273
  lineItem = {
274
+ id,
272
275
  type: "Product",
273
276
  productId: item.id,
274
277
  product: item,
@@ -287,7 +290,7 @@ function useCart() {
287
290
  const _ = storefront.pushOrderContent();
288
291
  },
289
292
  removeFromCart: (cartItem) => {
290
- const index = storefront.currentOrder.value.items.findIndex((i) => i.type === "Bundle" && cartItem.type === "Bundle" && i.bundleId === cartItem.bundleId || i.type === "Product" && cartItem.type === "Product" && i.productId === cartItem.productId);
293
+ const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItem.id);
291
294
  storefront.currentOrder.value.items.splice(index, 1);
292
295
  const _ = storefront.pushOrderContent();
293
296
  },
package/dist/index.js CHANGED
@@ -224,10 +224,12 @@ function useCart() {
224
224
  variation != null ? variation : variation = item.defaultVariation;
225
225
  if (!variation)
226
226
  throw new Error("Added item does not have a default variation, and none have been specified");
227
- let lineItem = storefront.currentOrder.value.items.find((i) => i.type === "Product" && i.productId === item.id && i.variationId === variation.id || i.type === "Bundle" && i.bundleId === item.id && i.variationId === variation.id);
227
+ const id = `b/${item.id}/${variation.id}`;
228
+ let lineItem = storefront.currentOrder.value.items.find((i) => i.id === id);
228
229
  if (!lineItem) {
229
230
  if (item.type === "bundle") {
230
231
  lineItem = {
232
+ id,
231
233
  type: "Bundle",
232
234
  bundleId: item.id,
233
235
  bundle: item,
@@ -237,6 +239,7 @@ function useCart() {
237
239
  storefront.currentOrder.value.items.push(lineItem);
238
240
  } else if (item.type === "product") {
239
241
  lineItem = {
242
+ id,
240
243
  type: "Product",
241
244
  productId: item.id,
242
245
  product: item,
@@ -255,7 +258,7 @@ function useCart() {
255
258
  const _ = storefront.pushOrderContent();
256
259
  },
257
260
  removeFromCart: (cartItem) => {
258
- const index = storefront.currentOrder.value.items.findIndex((i) => i.type === "Bundle" && cartItem.type === "Bundle" && i.bundleId === cartItem.bundleId || i.type === "Product" && cartItem.type === "Product" && i.productId === cartItem.productId);
261
+ const index = storefront.currentOrder.value.items.findIndex((i) => i.id === cartItem.id);
259
262
  storefront.currentOrder.value.items.splice(index, 1);
260
263
  const _ = storefront.pushOrderContent();
261
264
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/vue",
3
3
  "type": "module",
4
- "version": "0.1.43",
4
+ "version": "0.1.45",
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.43"
21
+ "@moonbase.sh/api-client": "0.1.45"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/uuid": "^9.0.7",