@laioutr/app-shopware 0.15.0 → 0.15.2
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { CHECKOUT_ENDPOINT_PATH, ADOPT_SESSION_ENDPOINT_PATH } from '../dist/run
|
|
|
4
4
|
import { registerLaioutrApp } from '@laioutr-core/kit';
|
|
5
5
|
|
|
6
6
|
const name = "@laioutr/app-shopware";
|
|
7
|
-
const version = "0.15.
|
|
7
|
+
const version = "0.15.2";
|
|
8
8
|
|
|
9
9
|
const module$1 = defineNuxtModule({
|
|
10
10
|
meta: {
|
|
@@ -3,16 +3,17 @@ import { createFallbackSlug, getEntitySeoSlug } from "./mappers/slugMapper.js";
|
|
|
3
3
|
import { mapMedia } from "./mediaMapper.js";
|
|
4
4
|
export const mapCartCost = (cart, currency) => {
|
|
5
5
|
const money = (value) => Money.fromDecimal(value, currency);
|
|
6
|
+
const zero = money(0);
|
|
6
7
|
const lineItems = cart.lineItems ?? [];
|
|
7
8
|
const deliveries = cart.deliveries ?? [];
|
|
8
9
|
const price = cart.price;
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
(sum, d) =>
|
|
15
|
-
|
|
10
|
+
const subtotal = price?.positionPrice === void 0 ? lineItems.reduce((sum, li) => sum.add(money(li.price?.totalPrice ?? 0)), zero) : money(price.positionPrice);
|
|
11
|
+
const total = price?.totalPrice === void 0 ? subtotal : money(price.totalPrice);
|
|
12
|
+
const shipping = deliveries.reduce((sum, d) => sum.add(money(d.shippingCosts?.totalPrice ?? 0)), zero);
|
|
13
|
+
const itemTax = (price?.calculatedTaxes ?? []).reduce((sum, t) => sum.add(money(t.tax ?? 0)), zero);
|
|
14
|
+
const shippingTax = deliveries.reduce(
|
|
15
|
+
(sum, d) => (d.shippingCosts?.calculatedTaxes ?? []).reduce((s, t) => s.add(money(t.tax ?? 0)), sum),
|
|
16
|
+
zero
|
|
16
17
|
);
|
|
17
18
|
const taxIncluded = price?.taxStatus === "gross";
|
|
18
19
|
const taxes = (price?.calculatedTaxes ?? []).map((t) => ({
|
|
@@ -20,12 +21,12 @@ export const mapCartCost = (cart, currency) => {
|
|
|
20
21
|
amount: money(t.tax ?? 0)
|
|
21
22
|
}));
|
|
22
23
|
return {
|
|
23
|
-
subtotal
|
|
24
|
+
subtotal,
|
|
24
25
|
subtotalIsEstimated: false,
|
|
25
|
-
total
|
|
26
|
+
total,
|
|
26
27
|
totalIsEstimated: false,
|
|
27
|
-
...deliveries.length > 0 ? { shipping: { total:
|
|
28
|
-
tax: { total:
|
|
28
|
+
...deliveries.length > 0 ? { shipping: { total: shipping, isEstimated: false } } : {},
|
|
29
|
+
tax: { total: itemTax.add(shippingTax), isEstimated: false, isIncluded: taxIncluded },
|
|
29
30
|
...taxes.length > 0 ? { taxes } : {}
|
|
30
31
|
};
|
|
31
32
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { FALLBACK_IMAGE, FALLBACK_IMAGE_URL } from "../const/fallbacks.js";
|
|
2
|
+
const encodeSpaces = (url) => url.replaceAll(" ", "%20");
|
|
2
3
|
export const mediaToSrc = (media) => {
|
|
3
4
|
if ((!media.thumbnails || media.thumbnails.length === 0) && !media.url) {
|
|
4
5
|
return FALLBACK_IMAGE_URL;
|
|
5
6
|
}
|
|
6
7
|
const thumbnails = media.thumbnails ?? [];
|
|
7
|
-
const thumbnailSrc = thumbnails.map((thumb) => `${thumb.url} ${thumb.width}x${thumb.height}`);
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const thumbnailSrc = thumbnails.map((thumb) => `${encodeSpaces(thumb.url)} ${thumb.width}x${thumb.height}`);
|
|
9
|
+
const mediaUrl = encodeSpaces(media.url);
|
|
10
|
+
const orgSrc = `${mediaUrl} ${media.metaData?.width ?? 0}x${media.metaData?.height ?? 0}`;
|
|
11
|
+
return `${mediaUrl}#${encodeURIComponent([...thumbnailSrc, orgSrc].join(", "))}`;
|
|
10
12
|
};
|
|
11
13
|
export const mapMediaSourceImage = (media) => {
|
|
12
14
|
const src = mediaToSrc(media);
|