@shopware-pwa/composables-next
Advanced tools
Comparing version 0.0.0-canary-20250114180306 to 0.0.0-canary-20250115104817
{ | ||
"name": "@shopware-pwa/composables-next", | ||
"version": "0.0.0-canary-20250114180306", | ||
"version": "0.0.0-canary-20250115104817", | ||
"description": "Shopware Frontends composables for Vue", | ||
@@ -57,4 +57,4 @@ "author": "Shopware", | ||
"scule": "1.3.0", | ||
"@shopware/api-client": "1.2.0", | ||
"@shopware-pwa/helpers-next": "1.2.0" | ||
"@shopware-pwa/helpers-next": "1.2.0", | ||
"@shopware/api-client": "1.2.0" | ||
}, | ||
@@ -61,0 +61,0 @@ "devDependencies": { |
@@ -168,3 +168,3 @@ # shopware/frontends - composables-next | ||
### Latest changes: 0.0.0-canary-20250114180306 | ||
### Latest changes: 0.0.0-canary-20250115104817 | ||
@@ -179,2 +179,5 @@ ### Minor Changes | ||
- [#1580](https://github.com/shopware/frontends/pull/1580) [`a04aa8c`](https://github.com/shopware/frontends/commit/a04aa8c0c705626bb231f8ead59c4c67a2d0d715) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Added `shippingCosts` property in `useCart` composable that returns shipping costs of the cart, with the shipping discounts. | ||
`shippingTotal` function is now deprecated as it only returns the first value from the array. The backend is returning a collection. | ||
- [#1550](https://github.com/shopware/frontends/pull/1550) [`63d56b3`](https://github.com/shopware/frontends/commit/63d56b3dacd6ca48a44744e387e6212a23c8bf4a) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - useCustomerOrders - Set current page based on the orders endpoint response |
@@ -218,2 +218,35 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; | ||
}); | ||
it("should return shipping costs", async () => { | ||
injections.apiClient.invoke.mockResolvedValue({ | ||
data: { | ||
deliveries: [ | ||
{ | ||
shippingMethod: { | ||
id: "a9d9cc502b3547f4a89eb2830c032c78", | ||
}, | ||
}, | ||
{ | ||
shippingMethod: { | ||
id: "a9d9cc502b3547f4a89eb2830c032c78", | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
await vm.refreshCart(); | ||
expect(vm.shippingCosts.length).toEqual(2); | ||
}); | ||
it("should return empty shipping costs", async () => { | ||
injections.apiClient.invoke.mockResolvedValue({ | ||
data: { | ||
deliveries: null, | ||
}, | ||
}); | ||
await vm.refreshCart(); | ||
expect(vm.shippingCosts.length).toEqual(0); | ||
}); | ||
}); |
@@ -69,5 +69,11 @@ import { createSharedComposable } from "@vueuse/core"; | ||
* Shipping price | ||
* | ||
* @deprecated Use `shippingCosts` instead | ||
*/ | ||
shippingTotal: ComputedRef<number>; | ||
/** | ||
* Shipping costs | ||
*/ | ||
shippingCosts: ComputedRef<Schemas["CartDelivery"][]>; | ||
/** | ||
* The total price of all cart items | ||
@@ -243,2 +249,6 @@ */ | ||
const shippingCosts = computed(() => { | ||
return cart.value?.deliveries || []; | ||
}); | ||
const subtotal = computed(() => { | ||
@@ -302,2 +312,3 @@ const cartPrice = cart.value?.price?.positionPrice; | ||
consumeCartErrors, | ||
shippingCosts, | ||
}; | ||
@@ -304,0 +315,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
762158
21247
182