@bestcheckout/dynamic-component-cli 0.1.12 → 0.1.15
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 +18 -0
- package/package.json +1 -1
- package/skills/checkout-theme-dynamic-development/references/behaviors.json +2 -2
- package/skills/checkout-theme-dynamic-development/references/component-catalog.json +113 -11
- package/skills/checkout-theme-dynamic-development/references/workflow.md +2 -0
- package/src/protocol/validation.mjs +14 -0
- package/types/index.d.ts +37 -4
package/README.md
CHANGED
|
@@ -150,6 +150,18 @@ A component exports a default definition containing `manifest`, `schema`, `defau
|
|
|
150
150
|
- `manifest.name` is the non-empty display name shown in the Editor, up to 128 Unicode characters.
|
|
151
151
|
- `manifest.supportedPageTypes` limits where the component can be selected. Omission means all four pages; an empty array means none. It does not grant runtime capabilities.
|
|
152
152
|
- `manifest.capabilities.offerRecommendation` is opt-in: set it to `true` only for an Upsell/Downsell component that owns the page's product recommendation rule. Ordinary content or interaction components omit it. Being placed on an offer page or reading `runtime.offer` recommendations does not require this declaration. The Editor uses the first rule provider in template order, including hidden sections.
|
|
153
|
+
- `manifest.capabilities.checkout` declares the functions a component provides when used in Checkout. Omit it for decorative components. Each supported key takes `true` or the name of a boolean setting. A conditional capability counts only when the saved instance `props` explicitly contains that setting with value `true`.
|
|
154
|
+
|
|
155
|
+
For example, an address component that writes to `runtime.checkout.delivery` can use:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
capabilities: { checkout: { delivery: true } }
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The Checkout Editor checks **Contact**, **Delivery**, **Shipping Method**, **Payment**, and **Order Summary** when you click Publish. If something is missing, the Editor lists what customers may be unable to do and asks you to confirm before publishing. Declare `contact`, `delivery`, `shippingMethod`, or `orderSummary` when your component provides that function. Declare `paymentForm` for a secure payment form, `paymentSubmit` for its submission action, or `paymentAuthorization` for a complete supported channel authorization action. A matching form and submit pair can be split across enabled components.
|
|
162
|
+
|
|
163
|
+
Save can keep an incomplete draft. Publish checks the current Checkout template and the declarations of its enabled components in their reviewed versions. A hidden or unplaced replacement does not count. A legacy dynamic component needs a declaration only when it supplies required coverage. The check verifies configuration and declarations. Use preview when available to verify that the component writes to the Host and that the buyer can complete the flow.
|
|
164
|
+
|
|
153
165
|
- `schema` is an array of Editor fields. Use `[]` when there are no settings.
|
|
154
166
|
- `defaultSettings` supplies values for new instances. It does not overwrite values already configured by a merchant.
|
|
155
167
|
- `Component` receives `{ settings, runtime, context }`.
|
|
@@ -289,6 +301,10 @@ Common actions return `{ ok: true }` or `{ ok: false, code, message? }`, with `c
|
|
|
289
301
|
|
|
290
302
|
`runtime.checkout.getSnapshot()` includes `contact`, read-only `lines`, optional `summary`, `currency`, `delivery`, `billing`, `shipping`, `coupon`, `payment` and `status`. `status.dataStatus` is `loading / ready / error / unknown`; `canSubmit` allows an attempt, while `blockedReasons` explains why it is blocked. The Host still revalidates on submission. Available actions:
|
|
291
303
|
|
|
304
|
+
Checkout has two currency concepts. `snapshot.currency` is the currency used for the page amounts in `lines` and `summary`. A payment method may settle in another currency when the selected provider returns a payable quote. In that case the Host exposes a display-only notice through `payment.methods[].description`, such as `Charged EUR 19.80`, and the native payment mount uses that quote internally. Components must not calculate an exchange rate, infer a quote from the checkout amount, or persist payment currency data. Use the current snapshot after a subscription update because both display amounts and payment method descriptions can change after address, shipping or payment-quote updates.
|
|
305
|
+
|
|
306
|
+
Checkout and Thank You may supply decimal amount text such as `lines[].displayPriceText`, `summary.totalText`, or `summary.discounts.order[].amountText`. These optional strings preserve decimal places and omit currency symbols. Use them for display with the corresponding snapshot currency, and fall back to the paired numeric amount and currency precision when the text is absent. `summary.shippingText` represents shipping after discounts, `summary.shippingOriginalPriceText` represents shipping before discounts, and `shipping.rates[].priceText` represents the individual quoted rate.
|
|
307
|
+
|
|
292
308
|
| Area | Methods |
|
|
293
309
|
| --- | --- |
|
|
294
310
|
| Contact | `contact.getState()`, `contact.setEmail(email)`, `contact.validate()` |
|
|
@@ -479,6 +495,8 @@ When replacing the current rule provider, copy its existing recommendation setti
|
|
|
479
495
|
|
|
480
496
|
#### Thank You runtime
|
|
481
497
|
|
|
498
|
+
Each child order's lines, summary, and amount text use that child's currency. Partial amounts may include text in `amounts` even when a complete `summary` is unavailable. `mergedOrderTotalText` accompanies `mergedOrderTotal` when a confirmed same-currency group total and its decimal text are available.
|
|
499
|
+
|
|
482
500
|
`runtime.order` is read-only:
|
|
483
501
|
|
|
484
502
|
- `getSnapshot()` and `subscribe(listener)` read the authenticated order state.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"cli_version": "0.1.
|
|
3
|
-
"runtime_types_sha256": "
|
|
2
|
+
"cli_version": "0.1.12",
|
|
3
|
+
"runtime_types_sha256": "ea72a31d00297c24bbc358841e18233b8f8ded092c23e48fac640683ea15d531",
|
|
4
4
|
"schema_version": 1,
|
|
5
5
|
"profiles": [
|
|
6
6
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"cli_version": "0.1.
|
|
3
|
-
"runtime_types_sha256": "
|
|
2
|
+
"cli_version": "0.1.12",
|
|
3
|
+
"runtime_types_sha256": "ea72a31d00297c24bbc358841e18233b8f8ded092c23e48fac640683ea15d531",
|
|
4
4
|
"page_types": [
|
|
5
5
|
"checkout",
|
|
6
6
|
"thankyou",
|
|
@@ -212,9 +212,15 @@
|
|
|
212
212
|
"key": "showSignInLink",
|
|
213
213
|
"equals": true
|
|
214
214
|
}
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"type": "css",
|
|
218
|
+
"key": "customCss",
|
|
219
|
+
"label": "Custom CSS"
|
|
215
220
|
}
|
|
216
221
|
],
|
|
217
222
|
"default_settings": {
|
|
223
|
+
"customCss": "",
|
|
218
224
|
"heading": "Contact",
|
|
219
225
|
"emailPlaceholder": "Email",
|
|
220
226
|
"showSignInLink": true,
|
|
@@ -615,9 +621,15 @@
|
|
|
615
621
|
"type": "text",
|
|
616
622
|
"key": "loadingText",
|
|
617
623
|
"label": "Loading text"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"type": "css",
|
|
627
|
+
"key": "customCss",
|
|
628
|
+
"label": "Custom CSS"
|
|
618
629
|
}
|
|
619
630
|
],
|
|
620
631
|
"default_settings": {
|
|
632
|
+
"customCss": "",
|
|
621
633
|
"text": "Pay now",
|
|
622
634
|
"fullWidth": true,
|
|
623
635
|
"loadingText": "Processing...",
|
|
@@ -703,9 +715,15 @@
|
|
|
703
715
|
"type": "toggle",
|
|
704
716
|
"key": "phoneRequired",
|
|
705
717
|
"label": "Require phone number"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"type": "css",
|
|
721
|
+
"key": "customCss",
|
|
722
|
+
"label": "Custom CSS"
|
|
706
723
|
}
|
|
707
724
|
],
|
|
708
725
|
"default_settings": {
|
|
726
|
+
"customCss": "",
|
|
709
727
|
"heading": "Delivery",
|
|
710
728
|
"countryLabel": "Country/Region",
|
|
711
729
|
"firstNamePlaceholder": "First name",
|
|
@@ -815,9 +833,15 @@
|
|
|
815
833
|
"type": "text",
|
|
816
834
|
"key": "heading",
|
|
817
835
|
"label": "Heading"
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
"type": "css",
|
|
839
|
+
"key": "customCss",
|
|
840
|
+
"label": "Custom CSS"
|
|
818
841
|
}
|
|
819
842
|
],
|
|
820
843
|
"default_settings": {
|
|
844
|
+
"customCss": "",
|
|
821
845
|
"heading": "Express checkout"
|
|
822
846
|
},
|
|
823
847
|
"default_blocks": [],
|
|
@@ -1914,6 +1938,7 @@
|
|
|
1914
1938
|
}
|
|
1915
1939
|
],
|
|
1916
1940
|
"default_settings": {
|
|
1941
|
+
"customCss": "",
|
|
1917
1942
|
"logoImage": "",
|
|
1918
1943
|
"logoWidthPc": 120,
|
|
1919
1944
|
"logoWidthMobile": 128,
|
|
@@ -1930,8 +1955,7 @@
|
|
|
1930
1955
|
"background": "",
|
|
1931
1956
|
"textColor": "",
|
|
1932
1957
|
"accentColor": "",
|
|
1933
|
-
"showDivider": true
|
|
1934
|
-
"customCss": ""
|
|
1958
|
+
"showDivider": true
|
|
1935
1959
|
},
|
|
1936
1960
|
"default_blocks": [],
|
|
1937
1961
|
"allowed_slots": {},
|
|
@@ -1984,9 +2008,15 @@
|
|
|
1984
2008
|
"type": "color",
|
|
1985
2009
|
"key": "totalColor",
|
|
1986
2010
|
"label": "Total color"
|
|
2011
|
+
},
|
|
2012
|
+
{
|
|
2013
|
+
"type": "css",
|
|
2014
|
+
"key": "customCss",
|
|
2015
|
+
"label": "Custom CSS"
|
|
1987
2016
|
}
|
|
1988
2017
|
],
|
|
1989
2018
|
"default_settings": {
|
|
2019
|
+
"customCss": "",
|
|
1990
2020
|
"heading": "Order summary",
|
|
1991
2021
|
"defaultState": "expanded",
|
|
1992
2022
|
"background": "",
|
|
@@ -2371,9 +2401,16 @@
|
|
|
2371
2401
|
"max": 24,
|
|
2372
2402
|
"step": 1,
|
|
2373
2403
|
"unit": "px"
|
|
2404
|
+
},
|
|
2405
|
+
{
|
|
2406
|
+
"type": "css",
|
|
2407
|
+
"key": "customCss",
|
|
2408
|
+
"label": "Custom CSS",
|
|
2409
|
+
"group": "Advanced"
|
|
2374
2410
|
}
|
|
2375
2411
|
],
|
|
2376
2412
|
"default_settings": {
|
|
2413
|
+
"customCss": "",
|
|
2377
2414
|
"recommendationRule": "bestSellers",
|
|
2378
2415
|
"maximumProducts": 4,
|
|
2379
2416
|
"specificProducts": [],
|
|
@@ -2509,6 +2546,7 @@
|
|
|
2509
2546
|
}
|
|
2510
2547
|
],
|
|
2511
2548
|
"default_settings": {
|
|
2549
|
+
"customCss": "",
|
|
2512
2550
|
"logoImage": "",
|
|
2513
2551
|
"logoTextFallback": "",
|
|
2514
2552
|
"logoAlignment": "left",
|
|
@@ -2518,8 +2556,7 @@
|
|
|
2518
2556
|
"viewOrderText": "View order confirmation",
|
|
2519
2557
|
"background": "#FFFFFF",
|
|
2520
2558
|
"textColor": "#000000",
|
|
2521
|
-
"accentColor": "#2563EB"
|
|
2522
|
-
"customCss": ""
|
|
2559
|
+
"accentColor": "#2563EB"
|
|
2523
2560
|
},
|
|
2524
2561
|
"default_blocks": [],
|
|
2525
2562
|
"allowed_slots": {},
|
|
@@ -2726,9 +2763,15 @@
|
|
|
2726
2763
|
"type": "color",
|
|
2727
2764
|
"key": "totalColor",
|
|
2728
2765
|
"label": "Total color"
|
|
2766
|
+
},
|
|
2767
|
+
{
|
|
2768
|
+
"type": "css",
|
|
2769
|
+
"key": "customCss",
|
|
2770
|
+
"label": "Custom CSS"
|
|
2729
2771
|
}
|
|
2730
2772
|
],
|
|
2731
2773
|
"default_settings": {
|
|
2774
|
+
"customCss": "",
|
|
2732
2775
|
"heading": "Order summary",
|
|
2733
2776
|
"showHeadingPc": true,
|
|
2734
2777
|
"showHeadingMobile": true,
|
|
@@ -2857,9 +2900,15 @@
|
|
|
2857
2900
|
"type": "text",
|
|
2858
2901
|
"key": "description",
|
|
2859
2902
|
"label": "Description"
|
|
2903
|
+
},
|
|
2904
|
+
{
|
|
2905
|
+
"type": "css",
|
|
2906
|
+
"key": "customCss",
|
|
2907
|
+
"label": "Custom CSS"
|
|
2860
2908
|
}
|
|
2861
2909
|
],
|
|
2862
2910
|
"default_settings": {
|
|
2911
|
+
"customCss": "",
|
|
2863
2912
|
"heading": "Payment",
|
|
2864
2913
|
"description": ""
|
|
2865
2914
|
},
|
|
@@ -3274,9 +3323,15 @@
|
|
|
3274
3323
|
"label": "Right"
|
|
3275
3324
|
}
|
|
3276
3325
|
]
|
|
3326
|
+
},
|
|
3327
|
+
{
|
|
3328
|
+
"type": "css",
|
|
3329
|
+
"key": "customCss",
|
|
3330
|
+
"label": "Custom CSS"
|
|
3277
3331
|
}
|
|
3278
3332
|
],
|
|
3279
3333
|
"default_settings": {
|
|
3334
|
+
"customCss": "",
|
|
3280
3335
|
"refundPolicyPage": "",
|
|
3281
3336
|
"privacyPolicyPage": "",
|
|
3282
3337
|
"termsOfServicePage": "",
|
|
@@ -3570,13 +3625,13 @@
|
|
|
3570
3625
|
}
|
|
3571
3626
|
],
|
|
3572
3627
|
"default_settings": {
|
|
3628
|
+
"customCss": "",
|
|
3573
3629
|
"orderConfirmedLabel": "Order confirmed",
|
|
3574
3630
|
"specialOfferLabel": "Special offer",
|
|
3575
3631
|
"completeLabel": "Complete",
|
|
3576
3632
|
"activeColor": "#121927",
|
|
3577
3633
|
"textColor": "#121927",
|
|
3578
|
-
"background": "#FFFFFF"
|
|
3579
|
-
"customCss": ""
|
|
3634
|
+
"background": "#FFFFFF"
|
|
3580
3635
|
},
|
|
3581
3636
|
"default_blocks": [],
|
|
3582
3637
|
"allowed_slots": {},
|
|
@@ -3902,7 +3957,7 @@
|
|
|
3902
3957
|
"default_settings": {
|
|
3903
3958
|
"heading": "Shipping Insurance",
|
|
3904
3959
|
"title": "Shipping insurance",
|
|
3905
|
-
"description": "Protect your shipment for just
|
|
3960
|
+
"description": "Protect your shipment for just {{price}}.",
|
|
3906
3961
|
"price": 3.95,
|
|
3907
3962
|
"orderSummaryImage": "",
|
|
3908
3963
|
"icon": "",
|
|
@@ -3955,9 +4010,15 @@
|
|
|
3955
4010
|
"type": "color",
|
|
3956
4011
|
"key": "selectedBorderColor",
|
|
3957
4012
|
"label": "Selected border color"
|
|
4013
|
+
},
|
|
4014
|
+
{
|
|
4015
|
+
"type": "css",
|
|
4016
|
+
"key": "customCss",
|
|
4017
|
+
"label": "Custom CSS"
|
|
3958
4018
|
}
|
|
3959
4019
|
],
|
|
3960
4020
|
"default_settings": {
|
|
4021
|
+
"customCss": "",
|
|
3961
4022
|
"heading": "Shipping method",
|
|
3962
4023
|
"emptyStateText": "Enter your shipping address to view available shipping methods.",
|
|
3963
4024
|
"selectedBorderColor": ""
|
|
@@ -4506,8 +4567,49 @@
|
|
|
4506
4567
|
"label": "Custom CSS"
|
|
4507
4568
|
}
|
|
4508
4569
|
],
|
|
4509
|
-
"default_settings": {
|
|
4510
|
-
|
|
4570
|
+
"default_settings": {
|
|
4571
|
+
"customCss": "",
|
|
4572
|
+
"heading": "Order summary",
|
|
4573
|
+
"showHeadingPc": true,
|
|
4574
|
+
"showHeadingMobile": true,
|
|
4575
|
+
"defaultState": "expanded",
|
|
4576
|
+
"background": "",
|
|
4577
|
+
"textColor": "",
|
|
4578
|
+
"totalColor": ""
|
|
4579
|
+
},
|
|
4580
|
+
"default_blocks": [
|
|
4581
|
+
{
|
|
4582
|
+
"id": "cartLines",
|
|
4583
|
+
"type": "cartLines",
|
|
4584
|
+
"enabled": true,
|
|
4585
|
+
"settings": {}
|
|
4586
|
+
},
|
|
4587
|
+
{
|
|
4588
|
+
"id": "subtotal",
|
|
4589
|
+
"type": "subtotal",
|
|
4590
|
+
"enabled": true,
|
|
4591
|
+
"settings": {
|
|
4592
|
+
"label": "Subtotal"
|
|
4593
|
+
}
|
|
4594
|
+
},
|
|
4595
|
+
{
|
|
4596
|
+
"id": "shipping",
|
|
4597
|
+
"type": "shipping",
|
|
4598
|
+
"enabled": true,
|
|
4599
|
+
"settings": {
|
|
4600
|
+
"label": "Shipping",
|
|
4601
|
+
"zeroValue": "free"
|
|
4602
|
+
}
|
|
4603
|
+
},
|
|
4604
|
+
{
|
|
4605
|
+
"id": "total",
|
|
4606
|
+
"type": "total",
|
|
4607
|
+
"enabled": true,
|
|
4608
|
+
"settings": {
|
|
4609
|
+
"label": "Total"
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
],
|
|
4511
4613
|
"allowed_slots": {},
|
|
4512
4614
|
"blocks": null,
|
|
4513
4615
|
"block_schemas": {
|
|
@@ -85,6 +85,8 @@ When integrating a component, preserve the selected page/template, supported pla
|
|
|
85
85
|
|
|
86
86
|
All Sections, including built-in/core Sections, support deletion and hiding. Keep placement, move and duplicate constraints separate from deletion permission. For a replacement implemented as a new instance, carry over the applicable settings and responsibilities, then delete the old instance; verify it is absent from both the page structure and rendered result. Do not finish a replacement by retaining a hidden old instance unless the user explicitly requests hiding or retaining it. An in-place edit requires no extra instance. During an incomplete or failed replacement, retain the original until the new path is ready and report the unfinished state accurately.
|
|
87
87
|
|
|
88
|
+
On Checkout, when replacing a core component, declare only the functions actually provided in `manifest.capabilities.checkout`. Use `contact`, `delivery`, `shippingMethod`, `paymentForm`, `paymentSubmit`, `paymentAuthorization`, and `orderSummary` as applicable. Save the replacement as an enabled instance. If a declaration names a boolean setting, set that instance prop to true. Checkout Publish checks coverage for the current template. Verify the actual Runtime interaction in preview when available.
|
|
89
|
+
|
|
88
90
|
On Upsell/Downsell, first distinguish an ordinary component from a recommendation-rule provider. Text, images, countdowns, custom interactions and views consuming existing `runtime.offer` data do not acquire `manifest.capabilities.offerRecommendation` merely because of their page type. Omit the capability and platform recommendation fields unless the component intentionally owns the page's rules. When replacing the active Offer/rule provider, preserve its existing rules in the replacement's instance props unless the user requested changes, then remove the old instance and read back the selected provider. Hidden providers still participate in selection by template order. Missing required recommendation configuration is a page-flow issue to resolve, not a reason to make a built-in Section undeletable.
|
|
89
91
|
|
|
90
92
|
When moving functions into a custom area, preserve authoritative configuration/data and avoid duplicate payment mounts, submission actions or charged selections. Do not hide/remove the existing providers until the new path covers their applicable responsibilities. Hiding a section does not prove its Host provider is inactive. If a fixed section cannot be moved or a public capability is missing, explain the specific limitation and use a supported layout rather than bypassing it.
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
var checkoutComponentCapabilities = [
|
|
2
|
+
"contact",
|
|
3
|
+
"delivery",
|
|
4
|
+
"shippingMethod",
|
|
5
|
+
"paymentForm",
|
|
6
|
+
"paymentSubmit",
|
|
7
|
+
"paymentAuthorization",
|
|
8
|
+
"orderSummary"
|
|
9
|
+
];
|
|
10
|
+
|
|
1
11
|
var offerRecommendationKeys = [
|
|
2
12
|
"recommendationRule",
|
|
3
13
|
"maximumProducts",
|
|
@@ -97,6 +107,10 @@ function validateDynamicManifest(value) {
|
|
|
97
107
|
error: "manifest.capabilities.offerRecommendation must be a boolean"
|
|
98
108
|
};
|
|
99
109
|
}
|
|
110
|
+
const checkout = isRecord(value.capabilities) ? value.capabilities.checkout : void 0;
|
|
111
|
+
if (checkout !== void 0 && (!isRecord(checkout) || Array.isArray(checkout) || Object.entries(checkout).some(([key, enabled]) => !checkoutComponentCapabilities.some((capability) => capability === key) || !(enabled === true || typeof enabled === "string" && enabled.trim() !== "")))) {
|
|
112
|
+
return { ok: false, error: "manifest.capabilities.checkout must map supported capabilities to true or a boolean setting key" };
|
|
113
|
+
}
|
|
100
114
|
return { ok: true, manifest: value };
|
|
101
115
|
}
|
|
102
116
|
function validateDynamicComponentDefinition(value) {
|
package/types/index.d.ts
CHANGED
|
@@ -10,12 +10,23 @@ export type DynamicComponentContext = {
|
|
|
10
10
|
mode: "editor" | "preview" | "live" | "storefront";
|
|
11
11
|
device: "desktop" | "mobile";
|
|
12
12
|
};
|
|
13
|
+
declare const checkoutComponentCapabilities: readonly [
|
|
14
|
+
"contact",
|
|
15
|
+
"delivery",
|
|
16
|
+
"shippingMethod",
|
|
17
|
+
"paymentForm",
|
|
18
|
+
"paymentSubmit",
|
|
19
|
+
"paymentAuthorization",
|
|
20
|
+
"orderSummary"
|
|
21
|
+
];
|
|
22
|
+
type CheckoutComponentCapability = typeof checkoutComponentCapabilities[number];
|
|
13
23
|
export type DynamicComponentManifest = {
|
|
14
24
|
componentId: string;
|
|
15
25
|
name: string;
|
|
16
26
|
supportedPageTypes?: readonly DynamicPageType[];
|
|
17
27
|
capabilities?: {
|
|
18
28
|
offerRecommendation?: boolean;
|
|
29
|
+
checkout?: Partial<Record<CheckoutComponentCapability, true | string>>;
|
|
19
30
|
};
|
|
20
31
|
};
|
|
21
32
|
type DynamicComponentRuntime = Record<string, unknown>;
|
|
@@ -264,6 +275,8 @@ type DynamicAccountRuntime = DynamicAccountActions & {
|
|
|
264
275
|
type CheckoutLineItemKind = "product" | "service" | "membership";
|
|
265
276
|
type CheckoutLinePromotion = {
|
|
266
277
|
label: string;
|
|
278
|
+
/** 展示金额独立于文案,避免预览优惠标签固定美元。 */
|
|
279
|
+
amount?: number;
|
|
267
280
|
};
|
|
268
281
|
type CheckoutLineItem = {
|
|
269
282
|
id: string;
|
|
@@ -276,7 +289,9 @@ type CheckoutLineItem = {
|
|
|
276
289
|
compareAtPrice?: number;
|
|
277
290
|
/** Display-level values supplied by the checkout calculation service. */
|
|
278
291
|
displayPrice?: number;
|
|
292
|
+
displayPriceText?: string;
|
|
279
293
|
displayCompareAtPrice?: number;
|
|
294
|
+
displayCompareAtPriceText?: string;
|
|
280
295
|
promotions?: CheckoutLinePromotion[];
|
|
281
296
|
sourceSectionId?: string;
|
|
282
297
|
sourceProductId?: string;
|
|
@@ -313,6 +328,7 @@ type CheckoutSummaryDiscount = {
|
|
|
313
328
|
id: string;
|
|
314
329
|
label: string;
|
|
315
330
|
amount: number;
|
|
331
|
+
amountText?: string;
|
|
316
332
|
};
|
|
317
333
|
type CheckoutSummaryDiscounts = {
|
|
318
334
|
order: CheckoutSummaryDiscount[];
|
|
@@ -323,6 +339,7 @@ type CheckoutShippingRate = {
|
|
|
323
339
|
title: string;
|
|
324
340
|
description?: string;
|
|
325
341
|
price: number;
|
|
342
|
+
priceText?: string;
|
|
326
343
|
};
|
|
327
344
|
type CheckoutExpressPaymentMethod = {
|
|
328
345
|
id: string;
|
|
@@ -470,6 +487,8 @@ type CheckoutBillingState = {
|
|
|
470
487
|
};
|
|
471
488
|
type CheckoutPreviewState = {
|
|
472
489
|
currencyCode?: string;
|
|
490
|
+
/** 店铺配置金额所属币种,用于识别尚无订单报价的附加服务。 */
|
|
491
|
+
originalCurrencyCode?: string;
|
|
473
492
|
currencySymbol: string;
|
|
474
493
|
currencyPrecision?: number;
|
|
475
494
|
isLoggedIn?: boolean;
|
|
@@ -535,6 +554,10 @@ type CheckoutRuntime = {
|
|
|
535
554
|
toggleConfiguredOffer?: (section: CheckoutSectionInstance, selected: boolean) => void | Promise<void>;
|
|
536
555
|
applyCoupon?: (code: string) => void | Promise<void>;
|
|
537
556
|
removeCoupon?: (code: string) => void | Promise<void>;
|
|
557
|
+
/** 可选覆盖优惠券 Apply 按钮内容;未传入时沿用内置 "Apply" / "Applying" 文案。 */
|
|
558
|
+
renderCouponApplyContent?: (props: {
|
|
559
|
+
isApplying: boolean;
|
|
560
|
+
}) => ReactNode;
|
|
538
561
|
setShippingRate?: (rateId: string) => void;
|
|
539
562
|
setPaymentMethod?: (method: string) => void;
|
|
540
563
|
startExpressCheckout?: (method: string) => void;
|
|
@@ -614,14 +637,18 @@ type CheckoutPreviewProductVariant = {
|
|
|
614
637
|
};
|
|
615
638
|
type CheckoutSummary = {
|
|
616
639
|
subtotal: number;
|
|
640
|
+
subtotalText?: string;
|
|
617
641
|
shipping: number;
|
|
642
|
+
shippingText?: string;
|
|
618
643
|
total: number;
|
|
644
|
+
totalText?: string;
|
|
619
645
|
savings: number;
|
|
646
|
+
savingsText?: string;
|
|
620
647
|
discounts: CheckoutSummaryDiscounts;
|
|
621
648
|
/** Only present when the Host has an authoritative tax amount; absence is unknown. */
|
|
622
649
|
tax?: number;
|
|
623
650
|
shippingOriginalPrice?: number;
|
|
624
|
-
|
|
651
|
+
shippingOriginalPriceText?: string;
|
|
625
652
|
};
|
|
626
653
|
type CheckoutAddress = {
|
|
627
654
|
name?: string;
|
|
@@ -675,6 +702,9 @@ type CheckoutThankYouSnapshot = {
|
|
|
675
702
|
shipping?: number;
|
|
676
703
|
total?: number;
|
|
677
704
|
tax?: number;
|
|
705
|
+
subtotalText?: string;
|
|
706
|
+
shippingText?: string;
|
|
707
|
+
totalText?: string;
|
|
678
708
|
};
|
|
679
709
|
reads?: {
|
|
680
710
|
main: CheckoutThankYouOrderRead;
|
|
@@ -684,6 +714,7 @@ type CheckoutThankYouSnapshot = {
|
|
|
684
714
|
orderSummaries?: CheckoutThankYouOrderSummary[];
|
|
685
715
|
/** Live-only group total supplied by post_purchase.total_paid. */
|
|
686
716
|
mergedOrderTotal?: number;
|
|
717
|
+
mergedOrderTotalText?: string;
|
|
687
718
|
/** Optional host-provided fulfillment progress; never inferred from totals. */
|
|
688
719
|
shippingProgress?: {
|
|
689
720
|
/** Zero-based index into steps, or the default Preparing/Shipped/Delivered steps. */
|
|
@@ -843,6 +874,8 @@ type PostPurchaseOfferPaymentAttempt = PostPurchaseOfferRepriceInput;
|
|
|
843
874
|
type PostPurchaseOfferActions = {
|
|
844
875
|
getSnapshot?: () => PostPurchaseOfferRuntime;
|
|
845
876
|
subscribe?: (listener: () => void) => () => void;
|
|
877
|
+
/** 让 Host 在重新报价前获知当前选择,立即离开时也能记录正确的规格和数量。 */
|
|
878
|
+
onSelectionChange?: (input: PostPurchaseOfferRepriceInput) => void;
|
|
846
879
|
reprice: (input: PostPurchaseOfferRepriceInput) => Promise<PostPurchaseOfferRepriceResult>;
|
|
847
880
|
accept: (input: PostPurchaseOfferRepriceInput) => Promise<PostPurchaseOfferAcceptResult>;
|
|
848
881
|
/** Reads one card's existing payment attempt without creating a new charge. */
|
|
@@ -950,7 +983,7 @@ declare function toCheckoutSnapshot(host: CheckoutRuntime, preview?: boolean): {
|
|
|
950
983
|
cityOptions: CheckoutDeliveryOption[];
|
|
951
984
|
};
|
|
952
985
|
shipping: {
|
|
953
|
-
rates: Pick<CheckoutShippingRate, "description" | "title" | "id" | "price">[];
|
|
986
|
+
rates: Pick<CheckoutShippingRate, "description" | "title" | "id" | "price" | "priceText">[];
|
|
954
987
|
selectedRateId: string;
|
|
955
988
|
isLoading: boolean | undefined;
|
|
956
989
|
error: string | undefined;
|
|
@@ -1055,7 +1088,7 @@ declare function createDynamicCheckoutAdapter(context: DynamicComponentContext,
|
|
|
1055
1088
|
cityOptions: CheckoutDeliveryOption[];
|
|
1056
1089
|
};
|
|
1057
1090
|
shipping: {
|
|
1058
|
-
rates: Pick<CheckoutShippingRate, "description" | "title" | "id" | "price">[];
|
|
1091
|
+
rates: Pick<CheckoutShippingRate, "description" | "title" | "id" | "price" | "priceText">[];
|
|
1059
1092
|
selectedRateId: string;
|
|
1060
1093
|
isLoading: boolean | undefined;
|
|
1061
1094
|
error: string | undefined;
|
|
@@ -1248,7 +1281,7 @@ declare function createDynamicCheckoutAdapter(context: DynamicComponentContext,
|
|
|
1248
1281
|
};
|
|
1249
1282
|
shipping: {
|
|
1250
1283
|
getState: () => {
|
|
1251
|
-
rates: Pick<CheckoutShippingRate, "description" | "title" | "id" | "price">[];
|
|
1284
|
+
rates: Pick<CheckoutShippingRate, "description" | "title" | "id" | "price" | "priceText">[];
|
|
1252
1285
|
selectedRateId: string;
|
|
1253
1286
|
isLoading: boolean | undefined;
|
|
1254
1287
|
error: string | undefined;
|