@aglyn/plugins-commerce 1.15.1 → 1.16.0
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/README.md +1 -1
- package/package.json +13 -13
- package/src/lib/components/cart.js +2 -1
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/console/payments-settings-card.component.js +6 -1
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-api.d.ts +5 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +2 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js +13 -6
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-tender-panel.component.js +7 -4
- package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -1
- package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
- package/src/lib/components/console/product-add-ons-fields.component.js +96 -3
- package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
- package/src/lib/components/console/product-builder-fields.component.d.ts +39 -0
- package/src/lib/components/console/product-builder-fields.component.js +195 -0
- package/src/lib/components/console/product-builder-fields.component.js.map +1 -0
- package/src/lib/components/console/product-editor-dialog.component.js +35 -2
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-editor-dialog.component.js +43 -6
- package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-messages.component.d.ts +21 -0
- package/src/lib/components/console/quote-messages.component.js +185 -0
- package/src/lib/components/console/quote-messages.component.js.map +1 -0
- package/src/lib/components/console/quote-pay-link.component.js +1 -1
- package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
- package/src/lib/components/console/quote-proofs.component.js +30 -3
- package/src/lib/components/console/quote-proofs.component.js.map +1 -1
- package/src/lib/components/console/quote-settings-card.component.d.ts +7 -3
- package/src/lib/components/console/quote-settings-card.component.js +154 -24
- package/src/lib/components/console/quote-settings-card.component.js.map +1 -1
- package/src/lib/components/product-builder-context.d.ts +22 -0
- package/src/lib/components/product-builder-context.js +21 -0
- package/src/lib/components/product-builder-context.js.map +1 -0
- package/src/lib/components/product-builder-mockup.d.ts +42 -0
- package/src/lib/components/product-builder-mockup.js +120 -0
- package/src/lib/components/product-builder-mockup.js.map +1 -0
- package/src/lib/components/product-builder-sample.d.ts +63 -0
- package/src/lib/components/product-builder-sample.js +96 -0
- package/src/lib/components/product-builder-sample.js.map +1 -0
- package/src/lib/components/product-choice-cards.d.ts +51 -0
- package/src/lib/components/product-choice-cards.js +311 -0
- package/src/lib/components/product-choice-cards.js.map +1 -0
- package/src/lib/components/product-detail-panels.d.ts +42 -0
- package/src/lib/components/product-detail-panels.js +185 -0
- package/src/lib/components/product-detail-panels.js.map +1 -0
- package/src/lib/components/product-detail.d.ts +20 -12
- package/src/lib/components/product-detail.js +136 -221
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.d.ts +7 -0
- package/src/lib/components/product-grid.js +11 -8
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/product-options-field-body.d.ts +9 -8
- package/src/lib/components/product-options-field-body.js +152 -3
- package/src/lib/components/product-options-field-body.js.map +1 -1
- package/src/lib/components/product-options-field.js +1 -1
- package/src/lib/components/product-options-field.js.map +1 -1
- package/src/lib/components/product-photo-fit.d.ts +49 -0
- package/src/lib/components/product-photo-fit.js +58 -0
- package/src/lib/components/product-photo-fit.js.map +1 -0
- package/src/lib/components/product-restock-notify.d.ts +12 -0
- package/src/lib/components/product-restock-notify.js +86 -0
- package/src/lib/components/product-restock-notify.js.map +1 -0
- package/src/lib/components/quote-messages-panel.d.ts +21 -0
- package/src/lib/components/quote-messages-panel.js +191 -0
- package/src/lib/components/quote-messages-panel.js.map +1 -0
- package/src/lib/components/quote-page-body.js +15 -1
- package/src/lib/components/quote-page-body.js.map +1 -1
- package/src/lib/components/quote-proof-panel.d.ts +6 -3
- package/src/lib/components/quote-proof-panel.js +139 -14
- package/src/lib/components/quote-proof-panel.js.map +1 -1
- package/src/lib/components/related-products.d.ts +7 -0
- package/src/lib/components/related-products.js +8 -6
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/constants/quote-page.d.ts +8 -0
- package/src/lib/constants/quote-page.js +11 -0
- package/src/lib/constants/quote-page.js.map +1 -1
- package/src/lib/model/commerce-cart.d.ts +6 -1
- package/src/lib/model/commerce-cart.js +5 -1
- package/src/lib/model/commerce-cart.js.map +1 -1
- package/src/lib/model/commerce-invoices.js +5 -1
- package/src/lib/model/commerce-invoices.js.map +1 -1
- package/src/lib/model/commerce-pos-ops.d.ts +3 -0
- package/src/lib/model/commerce-pos-ops.js +3 -0
- package/src/lib/model/commerce-pos-ops.js.map +1 -1
- package/src/lib/model/commerce-pos.d.ts +8 -0
- package/src/lib/model/commerce-pos.js.map +1 -1
- package/src/lib/model/commerce-quote-messages.d.ts +106 -0
- package/src/lib/model/commerce-quote-messages.js +146 -0
- package/src/lib/model/commerce-quote-messages.js.map +1 -0
- package/src/lib/model/commerce-quote-pay.d.ts +31 -2
- package/src/lib/model/commerce-quote-pay.js +31 -7
- package/src/lib/model/commerce-quote-pay.js.map +1 -1
- package/src/lib/model/commerce-quote-proofs.d.ts +47 -8
- package/src/lib/model/commerce-quote-proofs.js +73 -18
- package/src/lib/model/commerce-quote-proofs.js.map +1 -1
- package/src/lib/model/commerce-quote-request.d.ts +14 -4
- package/src/lib/model/commerce-quote-request.js +25 -2
- package/src/lib/model/commerce-quote-request.js.map +1 -1
- package/src/lib/model/commerce-quotes.d.ts +56 -3
- package/src/lib/model/commerce-quotes.js +47 -2
- package/src/lib/model/commerce-quotes.js.map +1 -1
- package/src/lib/model/commerce.d.ts +12 -1
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/pos-cellular.d.ts +5 -0
- package/src/lib/model/pos-cellular.js.map +1 -1
- package/src/lib/model/product-card-rules.d.ts +41 -0
- package/src/lib/model/product-card-rules.js +90 -0
- package/src/lib/model/product-card-rules.js.map +1 -0
- package/src/lib/model/product-modifiers.d.ts +11 -0
- package/src/lib/model/product-modifiers.js +10 -0
- package/src/lib/model/product-modifiers.js.map +1 -1
- package/src/lib/model/product-write.d.ts +3 -0
- package/src/lib/server/billing-webhook.js +6 -2
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +15 -0
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/channel-order-updates.js +15 -1
- package/src/lib/server/channel-order-updates.js.map +1 -1
- package/src/lib/server/channel-orders.js +20 -0
- package/src/lib/server/channel-orders.js.map +1 -1
- package/src/lib/server/checkout.js +1 -1
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/local-fulfillment.js +1 -1
- package/src/lib/server/local-fulfillment.js.map +1 -1
- package/src/lib/server/pos-cellular-billing.d.ts +1 -1
- package/src/lib/server/pos-cellular-billing.js +2 -1
- package/src/lib/server/pos-cellular-billing.js.map +1 -1
- package/src/lib/server/pos-cellular.d.ts +3 -1
- package/src/lib/server/pos-cellular.js +15 -8
- package/src/lib/server/pos-cellular.js.map +1 -1
- package/src/lib/server/pos-offline-sync.d.ts +3 -3
- package/src/lib/server/pos-offline-sync.js +17 -4
- package/src/lib/server/pos-offline-sync.js.map +1 -1
- package/src/lib/server/pos-order.js +17 -6
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.js +27 -11
- package/src/lib/server/pos-payment.js.map +1 -1
- package/src/lib/server/pos-reader-splash.js +10 -5
- package/src/lib/server/pos-reader-splash.js.map +1 -1
- package/src/lib/server/pos-readers.js +34 -10
- package/src/lib/server/pos-readers.js.map +1 -1
- package/src/lib/server/pos-return.js +19 -3
- package/src/lib/server/pos-return.js.map +1 -1
- package/src/lib/server/pos-stripe.d.ts +14 -0
- package/src/lib/server/pos-stripe.js +6 -2
- package/src/lib/server/pos-stripe.js.map +1 -1
- package/src/lib/server/pos-terminal-connection-token.js +23 -9
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +80 -14
- package/src/lib/server/pos-terminal.js +393 -123
- package/src/lib/server/pos-terminal.js.map +1 -1
- package/src/lib/server/product-drafts.d.ts +1 -1
- package/src/lib/server/product-drafts.js +4 -3
- package/src/lib/server/product-drafts.js.map +1 -1
- package/src/lib/server/product-writer.js +5 -4
- package/src/lib/server/product-writer.js.map +1 -1
- package/src/lib/server/product.d.ts +11 -0
- package/src/lib/server/product.js +18 -3
- package/src/lib/server/product.js.map +1 -1
- package/src/lib/server/products-write.js +4 -3
- package/src/lib/server/products-write.js.map +1 -1
- package/src/lib/server/quote-email.d.ts +26 -0
- package/src/lib/server/quote-email.js +73 -7
- package/src/lib/server/quote-email.js.map +1 -1
- package/src/lib/server/quote-messages.d.ts +72 -0
- package/src/lib/server/quote-messages.js +356 -0
- package/src/lib/server/quote-messages.js.map +1 -0
- package/src/lib/server/quote-pay.d.ts +42 -0
- package/src/lib/server/quote-pay.js +81 -4
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/quote-proofs.d.ts +1 -1
- package/src/lib/server/quote-proofs.js +63 -19
- package/src/lib/server/quote-proofs.js.map +1 -1
- package/src/lib/server/quote.d.ts +12 -0
- package/src/lib/server/quote.js +44 -14
- package/src/lib/server/quote.js.map +1 -1
- package/src/lib/server/refund.js +3 -1
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reserve-stock.js +9 -0
- package/src/lib/server/reserve-stock.js.map +1 -1
- package/src/lib/server/returns.js +15 -1
- package/src/lib/server/returns.js.map +1 -1
- package/src/lib/server/reviews.js +15 -0
- package/src/lib/server/reviews.js.map +1 -1
- package/src/lib/server/sold-out-drop.d.ts +58 -0
- package/src/lib/server/sold-out-drop.js +81 -0
- package/src/lib/server/sold-out-drop.js.map +1 -0
- package/src/lib/server/stock-levels.js +9 -0
- package/src/lib/server/stock-levels.js.map +1 -1
- package/src/lib/server/stripe-refund.d.ts +7 -0
- package/src/lib/server/stripe-refund.js +26 -7
- package/src/lib/server/stripe-refund.js.map +1 -1
- package/src/lib/server.js +2 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/tenant-emails.js +85 -2
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/testing/fake-seller-payment-account.d.ts +29 -0
- package/src/lib/testing/fake-seller-payment-account.js +40 -0
- package/src/lib/testing/fake-seller-payment-account.js.map +1 -0
- package/src/lib/transfer/product-transfer.js +6 -5
- package/src/lib/transfer/product-transfer.js.map +1 -1
- package/src/lib/transfer/products.server.js +4 -3
- package/src/lib/transfer/products.server.js.map +1 -1
- package/src/lib/utils/quote-email-content.d.ts +6 -0
- package/src/lib/utils/quote-email-content.js +6 -3
- package/src/lib/utils/quote-email-content.js.map +1 -1
|
@@ -22,22 +22,18 @@ import { buildBeginCheckoutParams, trackEvent, trackEventBeforeNavigation } from
|
|
|
22
22
|
import { isPaymentsNotConfigured } from "@aglyn/aglyn/app-utils/payments-configured";
|
|
23
23
|
import { storefrontPaymentsNotConfiguredText } from "../constants/storefront-payments.js";
|
|
24
24
|
import * as CommerceModel from "../model/index.js";
|
|
25
|
-
import {
|
|
26
|
-
import Accordion from "@mui/material/Accordion";
|
|
27
|
-
import AccordionDetails from "@mui/material/AccordionDetails";
|
|
28
|
-
import AccordionSummary from "@mui/material/AccordionSummary";
|
|
25
|
+
import { mdiTagOutline } from "@aglyn/shared-data-mdi";
|
|
29
26
|
import Alert from "@mui/material/Alert";
|
|
30
27
|
import Box from "@mui/material/Box";
|
|
31
28
|
import Button from "@mui/material/Button";
|
|
32
29
|
import Chip from "@mui/material/Chip";
|
|
33
30
|
import MenuItem from "@mui/material/MenuItem";
|
|
34
31
|
import Skeleton from "@mui/material/Skeleton";
|
|
35
|
-
import SvgIcon from "@mui/material/SvgIcon";
|
|
36
32
|
import TextField from "@mui/material/TextField";
|
|
37
33
|
import ToggleButton from "@mui/material/ToggleButton";
|
|
38
34
|
import ToggleButtonGroup from "@mui/material/ToggleButtonGroup";
|
|
39
35
|
import Typography from "@mui/material/Typography";
|
|
40
|
-
import { Suspense, forwardRef, lazy, useEffect, useMemo, useRef, useState } from "react";
|
|
36
|
+
import { Children, Suspense, forwardRef, lazy, useEffect, useMemo, useRef, useState } from "react";
|
|
41
37
|
import { BUNDLE_ID } from "../constants/bundle-common.js";
|
|
42
38
|
import { generatePresetId } from "../utils/generate-preset-id.js";
|
|
43
39
|
import { useStorefrontPurchaseEvent } from "../utils/use-storefront-purchase-event.js";
|
|
@@ -70,6 +66,16 @@ export const ID = 'product-detail';
|
|
|
70
66
|
* The add-on pickers (AGL-4100), in their own chunk: only a product with
|
|
71
67
|
* add-ons on the website downloads them.
|
|
72
68
|
*/ const ProductAddOns = /*#__PURE__*/ lazy(()=>import("./product-add-ons.js"));
|
|
69
|
+
/**
|
|
70
|
+
* The picture cards (AGL-4205), in their own chunk: only a page set to show
|
|
71
|
+
* its choices as cards downloads them.
|
|
72
|
+
*/ const ProductChoiceCards = /*#__PURE__*/ lazy(()=>import("./product-choice-cards.js"));
|
|
73
|
+
/**
|
|
74
|
+
* The free mockup's button and the request form it opens (AGL-4205), in their
|
|
75
|
+
* own chunk: only a product that offers one, or the canvas, downloads it.
|
|
76
|
+
*/ const ProductBuilderMockup = /*#__PURE__*/ lazy(()=>import("./product-builder-mockup.js"));
|
|
77
|
+
/** The back-in-stock alert, only on a sold-out variant (split out for AGL-4205). */ const ProductRestockNotify = /*#__PURE__*/ lazy(()=>import("./product-restock-notify.js"));
|
|
78
|
+
/** The Details and Shipping & returns folds (AGL-4205: split out), only where switched on. */ const ProductDetailPanels = /*#__PURE__*/ lazy(()=>import("./product-detail-panels.js"));
|
|
73
79
|
/** Money on the product page, in the store's currency: `$1,250.00`, never `$1250`. */ const money = (cents)=>CommerceModel.formatOrderMoney(cents);
|
|
74
80
|
/** A price in dollars as the page prints it. */ const moneyFromUsd = (priceUsd)=>money(Math.round(priceUsd * 100));
|
|
75
81
|
const SAMPLE = {
|
|
@@ -199,48 +205,6 @@ const SAMPLE = {
|
|
|
199
205
|
const first = (_ref = product == null ? void 0 : product.variants.find((variant)=>!variant.soldOut)) != null ? _ref : product == null ? void 0 : product.variants[0];
|
|
200
206
|
return _extends({}, (_ref1 = first == null ? void 0 : first.options) != null ? _ref1 : {});
|
|
201
207
|
}
|
|
202
|
-
/** What the Details panel lists: only facts the product record holds. */ export function productDetailFacts(product, variant, presented) {
|
|
203
|
-
var _product_tags;
|
|
204
|
-
const facts = [];
|
|
205
|
-
if (product.type === 'digital') facts.push({
|
|
206
|
-
label: 'Format',
|
|
207
|
-
value: 'Digital product'
|
|
208
|
-
});
|
|
209
|
-
if (product.type === 'service') facts.push({
|
|
210
|
-
label: 'Format',
|
|
211
|
-
value: 'Service'
|
|
212
|
-
});
|
|
213
|
-
for (const option of presented){
|
|
214
|
-
if (option.mode !== 'hidden') {
|
|
215
|
-
facts.push({
|
|
216
|
-
label: option.name,
|
|
217
|
-
value: option.values.join(', ')
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (variant == null ? void 0 : variant.sku) facts.push({
|
|
222
|
-
label: 'SKU',
|
|
223
|
-
value: variant.sku
|
|
224
|
-
});
|
|
225
|
-
if ((_product_tags = product.tags) == null ? void 0 : _product_tags.length) facts.push({
|
|
226
|
-
label: 'Tags',
|
|
227
|
-
value: product.tags.join(', ')
|
|
228
|
-
});
|
|
229
|
-
return facts;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* What the Shipping & returns panel says, from the product's kind and the
|
|
233
|
-
* store's own return settings — never a policy the store has not set.
|
|
234
|
-
*/ export function productShippingLines(product, returns) {
|
|
235
|
-
const lines = [];
|
|
236
|
-
if (product.type === 'digital') lines.push('Delivered digitally after purchase — nothing ships.');
|
|
237
|
-
else if (product.type === 'service') lines.push('A service — nothing ships.');
|
|
238
|
-
else lines.push('Shipping is calculated at checkout.');
|
|
239
|
-
if (returns && returns.windowDays > 0) {
|
|
240
|
-
lines.push(`Returns accepted within ${returns.windowDays} ` + `${returns.windowDays === 1 ? 'day' : 'days'} of shipping — ` + 'request one from your order status page.');
|
|
241
|
-
}
|
|
242
|
-
return lines;
|
|
243
|
-
}
|
|
244
208
|
function slugFromLocation() {
|
|
245
209
|
if (typeof window === 'undefined') return '';
|
|
246
210
|
const match = window.location.pathname.match(/\/products\/([^/?#]+)/);
|
|
@@ -253,16 +217,20 @@ function slugFromLocation() {
|
|
|
253
217
|
* variant. Resolves its product from the /products/{slug} URL unless a
|
|
254
218
|
* slug prop pins it; sample data on the inert canvas.
|
|
255
219
|
*/ const ProductDetail = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
256
|
-
var _ref, _ref1, _ref2, _ref3;
|
|
220
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
257
221
|
var _site_pageData;
|
|
258
|
-
const { slug: slugProp, buyLabel, hideDescription, showCoupon, showDetails, showShipping } = props, rest = _object_without_properties_loose(props, [
|
|
222
|
+
const { slug: slugProp, buyLabel, hideDescription, showCoupon, showDetails, showShipping, choiceStyle, mockupLabel, children } = props, rest = _object_without_properties_loose(props, [
|
|
259
223
|
"slug",
|
|
260
224
|
"buyLabel",
|
|
261
225
|
"hideDescription",
|
|
262
226
|
"showCoupon",
|
|
263
227
|
"showDetails",
|
|
264
|
-
"showShipping"
|
|
228
|
+
"showShipping",
|
|
229
|
+
"choiceStyle",
|
|
230
|
+
"mockupLabel",
|
|
231
|
+
"children"
|
|
265
232
|
]);
|
|
233
|
+
/** The product builder (AGL-4205): choices as picture cards. */ const cards = choiceStyle === 'cards';
|
|
266
234
|
// Node styles ride the renderer-merged sx; recompose (stack.ts pattern).
|
|
267
235
|
const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [
|
|
268
236
|
props['sx']
|
|
@@ -299,6 +267,21 @@ function slugFromLocation() {
|
|
|
299
267
|
/** A discount or coupon code typed on the product page. */ const [coupon, setCoupon] = useState('');
|
|
300
268
|
// A thumbnail the shopper picked; null follows the variant's own photo.
|
|
301
269
|
const [activeImage, setActiveImage] = useState(null);
|
|
270
|
+
/** The canvas's builder sample (AGL-4205), loaded only there, only for picture cards. */ const [sampleBuilder, setSampleBuilder] = useState(null);
|
|
271
|
+
useEffect(()=>{
|
|
272
|
+
if (hostId || !cards || sampleBuilder) return;
|
|
273
|
+
let active = true;
|
|
274
|
+
void import("./product-builder-sample.js").then((module)=>{
|
|
275
|
+
if (active) setSampleBuilder(module.SAMPLE_BUILDER);
|
|
276
|
+
});
|
|
277
|
+
return ()=>{
|
|
278
|
+
active = false;
|
|
279
|
+
};
|
|
280
|
+
}, [
|
|
281
|
+
hostId,
|
|
282
|
+
cards,
|
|
283
|
+
sampleBuilder
|
|
284
|
+
]);
|
|
302
285
|
// `unconfigured` is not an `error` with softer words (AGL-2019). A store
|
|
303
286
|
// with no Stripe key answers 501, and rendering that at `severity="error"`
|
|
304
287
|
// tells a shopper their payment failed when nothing was ever attempted —
|
|
@@ -323,8 +306,6 @@ function slugFromLocation() {
|
|
|
323
306
|
const [askPostal, setAskPostal] = useState(false);
|
|
324
307
|
const [added, setAdded] = useState(false);
|
|
325
308
|
const [wishlisted, setWishlisted] = useState(false);
|
|
326
|
-
const [notifyEmail, setNotifyEmail] = useState('');
|
|
327
|
-
const [notifyState, setNotifyState] = useState('idle');
|
|
328
309
|
// Buyer-chosen billing (AGL-545): only meaningful when the product
|
|
329
310
|
// is subscriptionOptional; defaults to a one-time purchase.
|
|
330
311
|
const [billing, setBilling] = useState('once');
|
|
@@ -380,7 +361,7 @@ function slugFromLocation() {
|
|
|
380
361
|
slug
|
|
381
362
|
]);
|
|
382
363
|
const resolvedId = hostId && detail && detail !== 'missing' ? detail.id : null;
|
|
383
|
-
const resolved = hostId ? detail === 'missing' ? null : detail : SAMPLE;
|
|
364
|
+
const resolved = hostId ? detail === 'missing' ? null : detail : cards ? sampleBuilder != null ? sampleBuilder : SAMPLE : SAMPLE;
|
|
384
365
|
const variant = useMemo(()=>{
|
|
385
366
|
var _CommerceModel_findVariant;
|
|
386
367
|
if (!resolved) return undefined;
|
|
@@ -672,8 +653,6 @@ function slugFromLocation() {
|
|
|
672
653
|
hostId
|
|
673
654
|
});
|
|
674
655
|
const presentedOptions = optionPresentation(resolved.options, resolved.variants);
|
|
675
|
-
const detailFacts = showDetails ? productDetailFacts(resolved, variant, presentedOptions) : [];
|
|
676
|
-
const shippingLines = showShipping ? productShippingLines(resolved, (seededProduct == null ? void 0 : seededProduct.id) === resolved.id ? seededReturns : undefined) : [];
|
|
677
656
|
// Subscription framing (AGL-545): subscription-only products price as
|
|
678
657
|
// $X/mo|/yr with a "Subscribe" button; subscriptionOptional products
|
|
679
658
|
// surface the one-time/subscribe toggle instead. Same price either way
|
|
@@ -684,6 +663,13 @@ function slugFromLocation() {
|
|
|
684
663
|
// Listed before it has a price (AGL-3676): no price to show and nothing
|
|
685
664
|
// to buy; every sale door would refuse it anyway.
|
|
686
665
|
const priced = typeof (variant == null ? void 0 : variant.priceUsd) === 'number';
|
|
666
|
+
// The add-ons are offered where they can be priced, and on a product that
|
|
667
|
+
// offers a free mockup, whose request carries them (AGL-4205).
|
|
668
|
+
// Live, the button shows only where the block holds a request form to
|
|
669
|
+
// open; on the canvas the block shows the space to drop one in.
|
|
670
|
+
const hasRequestForm = Children.toArray(children).length > 0;
|
|
671
|
+
const offersMockup = hostId ? resolved.mockupRequests === true && hasRequestForm : resolved.mockupRequests === true || hasRequestForm;
|
|
672
|
+
const showAddOns = addOnGroups.length > 0 && (priced || offersMockup);
|
|
687
673
|
// schema.org Product/Offer (AGL-299). Kept ONLY for the case where this
|
|
688
674
|
// block renders without server-seeded page data — the besigner preview,
|
|
689
675
|
// or a page whose resolver didn't supply it. When the tenant page seeds
|
|
@@ -881,9 +867,34 @@ function slugFromLocation() {
|
|
|
881
867
|
})
|
|
882
868
|
]
|
|
883
869
|
}) : null,
|
|
870
|
+
cards ? // The product builder (AGL-4205): every choice a picture card.
|
|
871
|
+
/*#__PURE__*/ _jsx(Suspense, {
|
|
872
|
+
fallback: null,
|
|
873
|
+
children: /*#__PURE__*/ _jsx(ProductChoiceCards, {
|
|
874
|
+
options: presentedOptions.filter((option)=>option.mode === 'select'),
|
|
875
|
+
variants: resolved.variants,
|
|
876
|
+
selections: (_ref4 = variant == null ? void 0 : variant.options) != null ? _ref4 : selections,
|
|
877
|
+
onSelect: (name, value)=>{
|
|
878
|
+
setActiveImage(null);
|
|
879
|
+
setSelections((prev)=>{
|
|
880
|
+
var _ref;
|
|
881
|
+
return _extends({}, (_ref = variant == null ? void 0 : variant.options) != null ? _ref : {}, prev, {
|
|
882
|
+
[name]: value
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
},
|
|
886
|
+
groups: showAddOns ? addOnGroups : [],
|
|
887
|
+
variantId: variant == null ? void 0 : variant.id,
|
|
888
|
+
value: addOns,
|
|
889
|
+
onChange: setAddOns,
|
|
890
|
+
formatCents: money,
|
|
891
|
+
unpricedLabel: PRICE_COMING_SOON_LABEL,
|
|
892
|
+
disabled: Boolean(variant == null ? void 0 : variant.soldOut)
|
|
893
|
+
})
|
|
894
|
+
}) : null,
|
|
884
895
|
presentedOptions.map((option)=>{
|
|
885
896
|
var _selections_option_name;
|
|
886
|
-
return option.mode === 'hidden' ? null : option.mode === 'text' ? /*#__PURE__*/ _jsx(Typography, {
|
|
897
|
+
return cards && option.mode === 'select' ? null : option.mode === 'hidden' ? null : option.mode === 'text' ? /*#__PURE__*/ _jsx(Typography, {
|
|
887
898
|
variant: "body2",
|
|
888
899
|
color: "text.secondary",
|
|
889
900
|
sx: {
|
|
@@ -912,7 +923,7 @@ function slugFromLocation() {
|
|
|
912
923
|
}, value))
|
|
913
924
|
}, option.name);
|
|
914
925
|
}),
|
|
915
|
-
|
|
926
|
+
showAddOns && !cards ? /*#__PURE__*/ _jsx(Suspense, {
|
|
916
927
|
fallback: null,
|
|
917
928
|
children: /*#__PURE__*/ _jsx(ProductAddOns, {
|
|
918
929
|
groups: addOnGroups,
|
|
@@ -967,10 +978,11 @@ function slugFromLocation() {
|
|
|
967
978
|
/*#__PURE__*/ _jsx(TextField, {
|
|
968
979
|
label: "Qty",
|
|
969
980
|
value: quantity,
|
|
970
|
-
onChange: (event)=>setQuantity(Math.max(1, Math.min(
|
|
981
|
+
onChange: (event)=>setQuantity(Math.max(1, Math.min(CommerceModel.CART_MAX_QUANTITY, Math.round(Number(event.target.value)) || 1))),
|
|
971
982
|
size: "small",
|
|
983
|
+
// Four digits fit (AGL-4205): a line goes up to 9,999.
|
|
972
984
|
sx: {
|
|
973
|
-
width:
|
|
985
|
+
width: (theme)=>theme.spacing(12)
|
|
974
986
|
},
|
|
975
987
|
slotProps: {
|
|
976
988
|
htmlInput: {
|
|
@@ -1007,10 +1019,11 @@ function slugFromLocation() {
|
|
|
1007
1019
|
})
|
|
1008
1020
|
]
|
|
1009
1021
|
}),
|
|
1010
|
-
addOnGroups.length && priced ? /*#__PURE__*/ _jsxs(Box, {
|
|
1022
|
+
(addOnGroups.length || cards) && priced ? /*#__PURE__*/ _jsxs(Box, {
|
|
1011
1023
|
sx: {
|
|
1012
1024
|
mb: 2
|
|
1013
1025
|
},
|
|
1026
|
+
"aria-live": "polite",
|
|
1014
1027
|
children: [
|
|
1015
1028
|
/*#__PURE__*/ _jsx(Typography, {
|
|
1016
1029
|
variant: "subtitle1",
|
|
@@ -1024,6 +1037,25 @@ function slugFromLocation() {
|
|
|
1024
1037
|
}) : null
|
|
1025
1038
|
]
|
|
1026
1039
|
}) : null,
|
|
1040
|
+
offersMockup ? /*#__PURE__*/ _jsx(Suspense, {
|
|
1041
|
+
fallback: null,
|
|
1042
|
+
children: /*#__PURE__*/ _jsx(ProductBuilderMockup, {
|
|
1043
|
+
picks: {
|
|
1044
|
+
product: resolved,
|
|
1045
|
+
variant,
|
|
1046
|
+
addOns,
|
|
1047
|
+
quantity,
|
|
1048
|
+
ready: pageAddOns.ready,
|
|
1049
|
+
problem: pageAddOns.ready ? undefined : pageAddOns.error,
|
|
1050
|
+
total: priced ? money(unitCents * quantity) : undefined
|
|
1051
|
+
},
|
|
1052
|
+
label: mockupLabel,
|
|
1053
|
+
priced: priced,
|
|
1054
|
+
canvas: !hostId,
|
|
1055
|
+
hasRequestForm: hasRequestForm,
|
|
1056
|
+
children: children
|
|
1057
|
+
})
|
|
1058
|
+
}) : null,
|
|
1027
1059
|
addRefusal ? /*#__PURE__*/ _jsx(Alert, {
|
|
1028
1060
|
severity: "warning",
|
|
1029
1061
|
sx: {
|
|
@@ -1117,60 +1149,14 @@ function slugFromLocation() {
|
|
|
1117
1149
|
},
|
|
1118
1150
|
children: message || 'Checkout is unavailable right now.'
|
|
1119
1151
|
}) : null,
|
|
1120
|
-
(variant == null ? void 0 : variant.soldOut) && hostId ?
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
display: 'flex',
|
|
1129
|
-
gap: 1,
|
|
1130
|
-
mb: 2
|
|
1131
|
-
},
|
|
1132
|
-
children: [
|
|
1133
|
-
/*#__PURE__*/ _jsx(TextField, {
|
|
1134
|
-
placeholder: "you@example.com",
|
|
1135
|
-
type: "email",
|
|
1136
|
-
// Third instance of the nameless-input defect (AGL-2392).
|
|
1137
|
-
// Named for its job rather than "Email address": this row
|
|
1138
|
-
// appears inside a product page that may also carry the
|
|
1139
|
-
// newsletter block, and two fields both announced as
|
|
1140
|
-
// "Email address" is barely better than none.
|
|
1141
|
-
slotProps: {
|
|
1142
|
-
htmlInput: {
|
|
1143
|
-
'aria-label': 'Email address for back-in-stock alert'
|
|
1144
|
-
}
|
|
1145
|
-
},
|
|
1146
|
-
value: notifyEmail,
|
|
1147
|
-
onChange: (event)=>setNotifyEmail(event.target.value),
|
|
1148
|
-
size: "small",
|
|
1149
|
-
sx: {
|
|
1150
|
-
flex: 1
|
|
1151
|
-
}
|
|
1152
|
-
}),
|
|
1153
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
1154
|
-
size: "small",
|
|
1155
|
-
variant: "outlined",
|
|
1156
|
-
disabled: !notifyEmail.trim(),
|
|
1157
|
-
onClick: async ()=>{
|
|
1158
|
-
const response = await siteFetch('/api/commerce/notify-restock', {
|
|
1159
|
-
method: 'POST',
|
|
1160
|
-
headers: {
|
|
1161
|
-
'Content-Type': 'application/json'
|
|
1162
|
-
},
|
|
1163
|
-
body: JSON.stringify({
|
|
1164
|
-
hostId,
|
|
1165
|
-
productId: resolved.id,
|
|
1166
|
-
email: notifyEmail
|
|
1167
|
-
})
|
|
1168
|
-
}).catch(()=>null);
|
|
1169
|
-
if (response == null ? void 0 : response.ok) setNotifyState('done');
|
|
1170
|
-
},
|
|
1171
|
-
children: 'Notify me'
|
|
1172
|
-
})
|
|
1173
|
-
]
|
|
1152
|
+
(variant == null ? void 0 : variant.soldOut) && hostId ? // The back-in-stock alert, only on a sold-out variant (its own chunk, AGL-4205).
|
|
1153
|
+
/*#__PURE__*/ _jsx(Suspense, {
|
|
1154
|
+
fallback: null,
|
|
1155
|
+
children: /*#__PURE__*/ _jsx(ProductRestockNotify, {
|
|
1156
|
+
hostId: hostId,
|
|
1157
|
+
productId: resolved.id,
|
|
1158
|
+
siteFetch: siteFetch
|
|
1159
|
+
})
|
|
1174
1160
|
}) : null,
|
|
1175
1161
|
!hideDescription && resolved.description ? /*#__PURE__*/ _jsx(Typography, {
|
|
1176
1162
|
variant: "body1",
|
|
@@ -1180,60 +1166,16 @@ function slugFromLocation() {
|
|
|
1180
1166
|
},
|
|
1181
1167
|
children: resolved.description
|
|
1182
1168
|
}) : null,
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
m: 0,
|
|
1194
|
-
display: 'grid',
|
|
1195
|
-
gridTemplateColumns: 'auto 1fr',
|
|
1196
|
-
columnGap: 2,
|
|
1197
|
-
rowGap: 0.75
|
|
1198
|
-
},
|
|
1199
|
-
children: detailFacts.map((fact)=>/*#__PURE__*/ _jsxs(Box, {
|
|
1200
|
-
sx: {
|
|
1201
|
-
display: 'contents'
|
|
1202
|
-
},
|
|
1203
|
-
children: [
|
|
1204
|
-
/*#__PURE__*/ _jsx(Typography, {
|
|
1205
|
-
component: "dt",
|
|
1206
|
-
variant: "body2",
|
|
1207
|
-
sx: {
|
|
1208
|
-
fontWeight: 600
|
|
1209
|
-
},
|
|
1210
|
-
children: fact.label
|
|
1211
|
-
}),
|
|
1212
|
-
/*#__PURE__*/ _jsx(Typography, {
|
|
1213
|
-
component: "dd",
|
|
1214
|
-
variant: "body2",
|
|
1215
|
-
color: "text.secondary",
|
|
1216
|
-
sx: {
|
|
1217
|
-
m: 0
|
|
1218
|
-
},
|
|
1219
|
-
children: fact.value
|
|
1220
|
-
})
|
|
1221
|
-
]
|
|
1222
|
-
}, fact.label))
|
|
1223
|
-
})
|
|
1224
|
-
}) : null,
|
|
1225
|
-
shippingLines.length ? /*#__PURE__*/ _jsx(ProductDetailPanel, {
|
|
1226
|
-
title: "Shipping & returns",
|
|
1227
|
-
children: shippingLines.map((line)=>/*#__PURE__*/ _jsx(Typography, {
|
|
1228
|
-
variant: "body2",
|
|
1229
|
-
color: "text.secondary",
|
|
1230
|
-
sx: {
|
|
1231
|
-
mb: 0.75
|
|
1232
|
-
},
|
|
1233
|
-
children: line
|
|
1234
|
-
}, line))
|
|
1235
|
-
}) : null
|
|
1236
|
-
]
|
|
1169
|
+
showDetails || showShipping ? /*#__PURE__*/ _jsx(Suspense, {
|
|
1170
|
+
fallback: null,
|
|
1171
|
+
children: /*#__PURE__*/ _jsx(ProductDetailPanels, {
|
|
1172
|
+
product: resolved,
|
|
1173
|
+
variant: variant,
|
|
1174
|
+
presented: presentedOptions,
|
|
1175
|
+
returns: (seededProduct == null ? void 0 : seededProduct.id) === resolved.id ? seededReturns : undefined,
|
|
1176
|
+
showDetails: Boolean(showDetails),
|
|
1177
|
+
showShipping: Boolean(showShipping)
|
|
1178
|
+
})
|
|
1237
1179
|
}) : null
|
|
1238
1180
|
]
|
|
1239
1181
|
})
|
|
@@ -1241,55 +1183,6 @@ function slugFromLocation() {
|
|
|
1241
1183
|
}));
|
|
1242
1184
|
});
|
|
1243
1185
|
ProductDetail.displayName = 'AglynProductDetail';
|
|
1244
|
-
/**
|
|
1245
|
-
* One fold of the panels under the buy box: a flat, divided accordion in the
|
|
1246
|
-
* theme's own colours — the way a designer storefront stacks Details and
|
|
1247
|
-
* Shipping under the description.
|
|
1248
|
-
*/ function ProductDetailPanel({ title, children }) {
|
|
1249
|
-
return /*#__PURE__*/ _jsxs(Accordion, {
|
|
1250
|
-
disableGutters: true,
|
|
1251
|
-
elevation: 0,
|
|
1252
|
-
square: true,
|
|
1253
|
-
sx: {
|
|
1254
|
-
bgcolor: 'transparent',
|
|
1255
|
-
borderTop: 1,
|
|
1256
|
-
borderColor: 'divider',
|
|
1257
|
-
'&:last-of-type': {
|
|
1258
|
-
borderBottom: 1,
|
|
1259
|
-
borderColor: 'divider'
|
|
1260
|
-
},
|
|
1261
|
-
'&::before': {
|
|
1262
|
-
display: 'none'
|
|
1263
|
-
}
|
|
1264
|
-
},
|
|
1265
|
-
children: [
|
|
1266
|
-
/*#__PURE__*/ _jsx(AccordionSummary, {
|
|
1267
|
-
expandIcon: /*#__PURE__*/ _jsx(SvgIcon, {
|
|
1268
|
-
fontSize: "small",
|
|
1269
|
-
children: /*#__PURE__*/ _jsx("path", {
|
|
1270
|
-
d: mdiChevronDown.path
|
|
1271
|
-
})
|
|
1272
|
-
}),
|
|
1273
|
-
sx: {
|
|
1274
|
-
px: 0
|
|
1275
|
-
},
|
|
1276
|
-
children: /*#__PURE__*/ _jsx(Typography, {
|
|
1277
|
-
variant: "subtitle1",
|
|
1278
|
-
component: "h2",
|
|
1279
|
-
children: title
|
|
1280
|
-
})
|
|
1281
|
-
}),
|
|
1282
|
-
/*#__PURE__*/ _jsx(AccordionDetails, {
|
|
1283
|
-
sx: {
|
|
1284
|
-
px: 0,
|
|
1285
|
-
pt: 0,
|
|
1286
|
-
pb: 2
|
|
1287
|
-
},
|
|
1288
|
-
children: children
|
|
1289
|
-
})
|
|
1290
|
-
]
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
1186
|
export const schema = {
|
|
1294
1187
|
$id: ID,
|
|
1295
1188
|
pluginId: BUNDLE_ID,
|
|
@@ -1302,9 +1195,8 @@ export const schema = {
|
|
|
1302
1195
|
color: '#2e7d32'
|
|
1303
1196
|
}
|
|
1304
1197
|
},
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
},
|
|
1198
|
+
// Not self-closing since AGL-4205: what is dropped in is the request form
|
|
1199
|
+
// "Get a free mockup" opens, shown only for a product that offers one.
|
|
1308
1200
|
attributes: [
|
|
1309
1201
|
{
|
|
1310
1202
|
name: 'slug',
|
|
@@ -1346,6 +1238,29 @@ export const schema = {
|
|
|
1346
1238
|
label: 'Show shipping & returns panel',
|
|
1347
1239
|
description: 'A Shipping & returns fold: shipping priced at checkout (or digital ' + 'delivery), and your return window when your store takes returns.',
|
|
1348
1240
|
component: Aglyn.FieldComponentType.CHECKBOX
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
// AGL-4205. Absent reads as menus, so no existing page changes shape.
|
|
1244
|
+
name: 'choiceStyle',
|
|
1245
|
+
label: 'Show choices as',
|
|
1246
|
+
description: 'Menus, or picture cards: a card per choice with its picture, price and note, and a running total.',
|
|
1247
|
+
component: Aglyn.FieldComponentType.SELECT,
|
|
1248
|
+
options: [
|
|
1249
|
+
{
|
|
1250
|
+
label: 'Menus',
|
|
1251
|
+
value: 'menus'
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
label: 'Picture cards',
|
|
1255
|
+
value: 'cards'
|
|
1256
|
+
}
|
|
1257
|
+
]
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
name: 'mockupLabel',
|
|
1261
|
+
label: 'Free mockup button label',
|
|
1262
|
+
description: 'Shown when the product offers a free mockup and this block holds a request form.',
|
|
1263
|
+
component: Aglyn.FieldComponentType.TEXT_FIELD
|
|
1349
1264
|
}
|
|
1350
1265
|
]
|
|
1351
1266
|
};
|