@base44/app-plugin-commerce 0.2.4 → 0.2.6
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/package.json +1 -1
- package/skills/commerce/SKILL.md +64 -76
- package/skills/commerce/docs/api-admin.md +11 -50
- package/skills/commerce/docs/api-storefront.md +25 -118
- package/skills/commerce/install/01-install.md +20 -49
- package/skills/commerce/install/02-storefront.md +185 -319
- package/skills/commerce/install/03-data.md +43 -106
- package/skills/commerce/references/admin-product-form.md +26 -0
- package/skills/commerce/references/catalog-rendering.md +8 -8
- package/skills/commerce/references/online-payments.md +4 -15
- package/skills/commerce/references/operations.md +19 -1
- package/skills/commerce/references/storefront-verification.md +47 -0
- package/src/commerce/storefront/StorefrontProvider.jsx +45 -8
- package/src/commerce/storefront/cartUI.jsx +190 -0
- package/src/commerce/storefront/index.js +50 -20
- package/src/commerce/storefront/pickers.jsx +98 -23
- package/src/commerce/storefront/useAddressForm.js +71 -25
- package/src/commerce/storefront/useCartLine.js +40 -4
- package/src/commerce/storefront/useCheckout.jsx +13 -0
- package/src/commerce/storefront/useOrderReturn.js +7 -5
- package/src/commerce/storefront/usePlaceOrder.js +55 -0
- package/src/commerce/storefront/useProduct.js +93 -13
- package/src/commerce/storefront/useProductList.js +12 -0
- package/src/commerce/storefront/useUpsell.js +90 -0
- package/src/commerce/utils/index.js +3 -2
- package/src/commerce/utils/specs.js +104 -17
- package/src/commerce/utils/totals.js +23 -12
|
@@ -91,20 +91,31 @@ export function orderTotalsLines(order, { formatMoney, labels = {} } = {}) {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* An order's line items in the same shape as decorated cart lines, so one
|
|
94
|
-
* component renders the bag, the checkout summary and the confirmation
|
|
94
|
+
* component renders the bag, the checkout summary and the confirmation —
|
|
95
|
+
* `image` is `{src, alt}|null` and `totalLabel` is pre-formatted, exactly as
|
|
96
|
+
* on `useCart().lines` (pass `formatMoney`; `useOrderReturn` does).
|
|
95
97
|
*
|
|
96
98
|
* @param {object} order
|
|
99
|
+
* @param {{formatMoney?: (n: number) => string}} [opts]
|
|
97
100
|
* @returns {Array<{name: string, attributesLabel: string, quantity: number,
|
|
98
|
-
* total: number, image:
|
|
101
|
+
* total: number, totalLabel: string, image: {src: string, alt: string}|null,
|
|
102
|
+
* sku: string}>}
|
|
99
103
|
*/
|
|
100
|
-
export function orderLines(order) {
|
|
101
|
-
return (order?.line_items ?? []).map((it) =>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
export function orderLines(order, { formatMoney } = {}) {
|
|
105
|
+
return (order?.line_items ?? []).map((it) => {
|
|
106
|
+
const total = num(it.total ?? it.subtotal);
|
|
107
|
+
// An order item's image may be stored as a bare URL or an object — either
|
|
108
|
+
// way it leaves here as {src, alt}|null, the cart-line shape.
|
|
109
|
+
const src = typeof it.image === "string" ? it.image : it.image?.src;
|
|
110
|
+
return {
|
|
111
|
+
...it,
|
|
112
|
+
name: it.name ?? "",
|
|
113
|
+
attributesLabel: attributesLabel(it.attributes ?? it.meta_data),
|
|
114
|
+
quantity: num(it.quantity),
|
|
115
|
+
total,
|
|
116
|
+
totalLabel: money(formatMoney, total),
|
|
117
|
+
image: src ? { src, alt: (typeof it.image === "object" ? it.image?.alt : "") || it.name || "" } : null,
|
|
118
|
+
sku: it.sku ?? "",
|
|
119
|
+
};
|
|
120
|
+
});
|
|
110
121
|
}
|