@vectoriox/iox-ui 5.96.2 → 5.98.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/commerce-core/index.d.ts +274 -2
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +312 -1
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +2 -8
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1114 -223
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +115 -42
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/generation-core/index.d.ts +515 -17
- package/harness-core/index.d.ts +66 -6
- package/package.json +1 -1
- package/src/commerce-core/public-api.ts +2 -0
- package/src/commerce-core/shipping.ts +22 -0
- package/src/commerce-core/site-checkout.ts +406 -0
- package/src/commerce-core/variants.ts +20 -0
- package/src/composite-core/shop-runtime.ts +2 -8
- package/src/generation-core/audit-site.ts +8 -0
- package/src/generation-core/compose-site.ts +130 -4
- package/src/generation-core/nav-shape.ts +4 -2
- package/src/generation-core/patterns.ts +25 -1
- package/src/generation-core/pictures.ts +1 -1
- package/src/generation-core/plan-derived.ts +10 -5
- package/src/generation-core/plan-edits.ts +8 -7
- package/src/generation-core/plan-wire.ts +59 -10
- package/src/generation-core/plan-words.ts +18 -1
- package/src/generation-core/public-api.ts +1 -0
- package/src/generation-core/shop-plan.ts +165 -0
- package/src/generation-core/showcase.ts +29 -4
- package/src/generation-core/site-build-run.ts +25 -0
- package/src/generation-core/site-plan.model.ts +49 -1
- package/src/generation-core/site-spec.generated.ts +330 -2
- package/src/generation-core/stock-photos.ts +19 -2
- package/src/generation-core/validate-site-plan.ts +146 -8
- package/src/harness-core/business-types.ts +13 -0
- package/src/harness-core/harness-spec.generated.ts +69 -39
- package/src/harness-core/needs.ts +30 -1
- package/src/harness-core/site-reading.ts +8 -2
package/commerce-core/index.d.ts
CHANGED
|
@@ -228,6 +228,14 @@ declare function quoteShipping(methods: readonly ShippingMethod[], cart: Shippin
|
|
|
228
228
|
* where anything ships never is.
|
|
229
229
|
*/
|
|
230
230
|
declare function availableShippingMethods(methods: readonly ShippingMethod[], pricedCart: ShippingCart): ShippingQuote[];
|
|
231
|
+
/**
|
|
232
|
+
* What the goods still lack before a free-over method delivers free (the drawer's "Add ₪X more for free delivery"):
|
|
233
|
+
* the smallest gap over the methods offered, null when nothing ships, when no method is free-over, or when one already
|
|
234
|
+
* is free. `methods` are the ready ones (the checkout's options answer only those).
|
|
235
|
+
*/
|
|
236
|
+
declare function freeShippingRemaining(methods: ReadonlyArray<Pick<ShippingMethod, 'kind'> & {
|
|
237
|
+
freeOver?: Money | null;
|
|
238
|
+
}>, cart: Pick<ShippingCart, 'currency' | 'subtotal' | 'discount' | 'requiresShipping' | 'lines'>): Money | null;
|
|
231
239
|
|
|
232
240
|
/** A cart names what and how many — never a price (C-D16, trap T1): every read prices it again. */
|
|
233
241
|
interface CartLine {
|
|
@@ -751,6 +759,17 @@ declare function variantWords(choice: VariantChoice, options: ReadonlyArray<Prod
|
|
|
751
759
|
* data holds (a product page bound to one product). Null when the page has none.
|
|
752
760
|
*/
|
|
753
761
|
declare function productInScope(rowItem: unknown, data: Readonly<Record<string, unknown>> | null | undefined): StorefrontProduct | null;
|
|
762
|
+
/** What the `$variant` slot carries: the chosen variant, its product, its words and the quantity a buyer would add. */
|
|
763
|
+
interface VariantSlot extends ProductVariantView {
|
|
764
|
+
productId: string | undefined;
|
|
765
|
+
words: string;
|
|
766
|
+
quantity: number;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* The `$variant` slot for a product — the SAME value the shop runtime publishes on the canvas and the live site, and
|
|
770
|
+
* the engine seeds during SSR (so the raw HTML already shows the price). `choice` defaults to the first sellable one.
|
|
771
|
+
*/
|
|
772
|
+
declare function variantSlotOf(product: StorefrontProduct | null | undefined, choice?: VariantChoice | null, quantity?: number): VariantSlot | null;
|
|
754
773
|
|
|
755
774
|
/**
|
|
756
775
|
* The quantity a buyer may ask for — the stepper on a product page and on every cart line (commerce plan §3i). Whole
|
|
@@ -944,5 +963,258 @@ declare const SAMPLE_CART_LINE: Readonly<{
|
|
|
944
963
|
quantity: 1;
|
|
945
964
|
}>;
|
|
946
965
|
|
|
947
|
-
|
|
948
|
-
|
|
966
|
+
/**
|
|
967
|
+
* The fixed checkout (C-D3) and the order page as a SITE reads them over iox-cms's public routes (`shop.md` "E1 site
|
|
968
|
+
* API"): the routes, the answers' shapes, the words, and how a refusal's `code` becomes a sentence on the field it is
|
|
969
|
+
* about. The engine renders; iox-cms prices (trap T1) — nothing here computes a total.
|
|
970
|
+
*/
|
|
971
|
+
declare enum SiteCommerceRoute {
|
|
972
|
+
Cart = "cart",
|
|
973
|
+
CartLines = "cart/lines",
|
|
974
|
+
CheckoutOptions = "checkout/options",
|
|
975
|
+
Checkout = "checkout",
|
|
976
|
+
CheckoutPlace = "checkout/place",
|
|
977
|
+
Order = "order"
|
|
978
|
+
}
|
|
979
|
+
/** A public commerce route of one org, ROOT-relative (the same rule as `cartEndpointPath`). */
|
|
980
|
+
declare function siteCommercePath(orgId: string, route: SiteCommerceRoute, id?: string | null): string;
|
|
981
|
+
/** The cart cookie iox-cms sets for one org (httpOnly — a site script never reads it; SSR forwards it). */
|
|
982
|
+
declare const CART_COOKIE_PREFIX = "iox_cart_";
|
|
983
|
+
declare function cartCookieName(orgId: string): string;
|
|
984
|
+
/** The order page under the checkout: `/<orgLabel>/checkout/order/<token>`. */
|
|
985
|
+
declare const ORDER_PATH = "order";
|
|
986
|
+
declare function orderHref(orgLabel: string | null | undefined, token: string): string;
|
|
987
|
+
declare enum CheckoutFieldMode {
|
|
988
|
+
Hidden = "hidden",
|
|
989
|
+
Optional = "optional",
|
|
990
|
+
Required = "required"
|
|
991
|
+
}
|
|
992
|
+
/** The contact fields an owner may hide, offer or require. */
|
|
993
|
+
declare enum CheckoutAskedField {
|
|
994
|
+
Phone = "phone",
|
|
995
|
+
Company = "company",
|
|
996
|
+
Note = "note"
|
|
997
|
+
}
|
|
998
|
+
type CheckoutFieldModes = Readonly<Partial<Record<CheckoutAskedField, CheckoutFieldMode>>>;
|
|
999
|
+
interface SitePaymentOption {
|
|
1000
|
+
kind: PaymentMethodKind;
|
|
1001
|
+
label: CommerceLabel;
|
|
1002
|
+
fit: DeliveryFit;
|
|
1003
|
+
}
|
|
1004
|
+
interface SiteShippingMethod {
|
|
1005
|
+
id: string;
|
|
1006
|
+
kind: ShippingMethodKind;
|
|
1007
|
+
name: string;
|
|
1008
|
+
price: Money | null;
|
|
1009
|
+
freeOver: Money | null;
|
|
1010
|
+
pickupAddress: string | null;
|
|
1011
|
+
pickupHours: string | null;
|
|
1012
|
+
needsAddress: boolean;
|
|
1013
|
+
}
|
|
1014
|
+
interface SiteLegalLink {
|
|
1015
|
+
title: string;
|
|
1016
|
+
path: string;
|
|
1017
|
+
}
|
|
1018
|
+
/** `GET checkout/options` — what the page renders before anything is typed. */
|
|
1019
|
+
interface SiteCheckoutOptions {
|
|
1020
|
+
open: boolean;
|
|
1021
|
+
plan: string;
|
|
1022
|
+
refusals: string[];
|
|
1023
|
+
currency: CurrencyCode;
|
|
1024
|
+
vatPercent: number;
|
|
1025
|
+
country: string | null;
|
|
1026
|
+
shippingMethods: SiteShippingMethod[];
|
|
1027
|
+
paymentMethods: SitePaymentOption[];
|
|
1028
|
+
fields: CheckoutFieldModes;
|
|
1029
|
+
legalPages: Readonly<Partial<Record<LegalPage, SiteLegalLink | null>>>;
|
|
1030
|
+
business: BusinessIdentity;
|
|
1031
|
+
siteName: string | null;
|
|
1032
|
+
marketingWording: CommerceLabel;
|
|
1033
|
+
}
|
|
1034
|
+
interface SiteCheckoutContact {
|
|
1035
|
+
email: string;
|
|
1036
|
+
name: string | null;
|
|
1037
|
+
phone: string | null;
|
|
1038
|
+
company: string | null;
|
|
1039
|
+
}
|
|
1040
|
+
interface SiteShippingOption extends ShippingQuote {
|
|
1041
|
+
pickupAddress: string | null;
|
|
1042
|
+
pickupHours: string | null;
|
|
1043
|
+
}
|
|
1044
|
+
/** `GET|POST|PATCH checkout` — one checkout, priced by the server. */
|
|
1045
|
+
interface SiteCheckoutView {
|
|
1046
|
+
id: string;
|
|
1047
|
+
contact: SiteCheckoutContact;
|
|
1048
|
+
language: string;
|
|
1049
|
+
marketingConsent: {
|
|
1050
|
+
given: boolean;
|
|
1051
|
+
wording: string;
|
|
1052
|
+
};
|
|
1053
|
+
delivery: {
|
|
1054
|
+
methodId: string;
|
|
1055
|
+
address: PostalAddress | null;
|
|
1056
|
+
} | null;
|
|
1057
|
+
payment: {
|
|
1058
|
+
kind: PaymentMethodKind;
|
|
1059
|
+
label: string;
|
|
1060
|
+
} | null;
|
|
1061
|
+
note: string | null;
|
|
1062
|
+
furthestStep: CheckoutStep;
|
|
1063
|
+
status: string;
|
|
1064
|
+
cart: SiteCartView;
|
|
1065
|
+
shippingOptions: SiteShippingOption[];
|
|
1066
|
+
paymentOptions: SitePaymentOption[];
|
|
1067
|
+
fields: CheckoutFieldModes;
|
|
1068
|
+
termsRequired: boolean;
|
|
1069
|
+
}
|
|
1070
|
+
/** `GET order/:token` — the buyer's own order (instructions only while it waits for the money). */
|
|
1071
|
+
interface SiteBuyerOrder {
|
|
1072
|
+
number: string | number;
|
|
1073
|
+
state: OrderState;
|
|
1074
|
+
stateLabel: string;
|
|
1075
|
+
placedAt: string;
|
|
1076
|
+
language: string;
|
|
1077
|
+
seller: {
|
|
1078
|
+
name: string;
|
|
1079
|
+
business: BusinessIdentity;
|
|
1080
|
+
};
|
|
1081
|
+
snapshot: OrderSnapshot;
|
|
1082
|
+
paymentLabel: string;
|
|
1083
|
+
instructions: string | null;
|
|
1084
|
+
}
|
|
1085
|
+
/** `POST checkout/place` — 201. */
|
|
1086
|
+
interface SitePlacedOrder {
|
|
1087
|
+
order: SiteBuyerOrder;
|
|
1088
|
+
viewToken: string;
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* The step to SHOW: no checkout yet is Contact; then the first step still missing what it needs — a delivery chosen
|
|
1092
|
+
* (with an address when it delivers), then a payment. A step already passed stays open only when the buyer asks.
|
|
1093
|
+
*/
|
|
1094
|
+
declare function currentCheckoutStep(view: Pick<SiteCheckoutView, 'delivery' | 'payment' | 'shippingOptions'> | null | undefined): CheckoutStep;
|
|
1095
|
+
/** The steps the stepper names (Paid is the order page, never a step a buyer fills). */
|
|
1096
|
+
declare const CHECKOUT_FORM_STEPS: readonly CheckoutStep[];
|
|
1097
|
+
declare function fieldAsked(fields: CheckoutFieldModes | null | undefined, field: CheckoutAskedField): boolean;
|
|
1098
|
+
declare function fieldRequired(fields: CheckoutFieldModes | null | undefined, field: CheckoutAskedField): boolean;
|
|
1099
|
+
/** One line of a postal address as a buyer reads it. */
|
|
1100
|
+
declare function addressLine(address: PostalAddress | null | undefined): string;
|
|
1101
|
+
declare enum CheckoutWord {
|
|
1102
|
+
SecureCheckout = "secureCheckout",
|
|
1103
|
+
Email = "email",
|
|
1104
|
+
Name = "name",
|
|
1105
|
+
Phone = "phone",
|
|
1106
|
+
Company = "company",
|
|
1107
|
+
Optional = "optional",
|
|
1108
|
+
ContinueToDelivery = "continueToDelivery",
|
|
1109
|
+
ContinueToPayment = "continueToPayment",
|
|
1110
|
+
Change = "change",
|
|
1111
|
+
Street = "street",
|
|
1112
|
+
StreetMore = "streetMore",
|
|
1113
|
+
City = "city",
|
|
1114
|
+
PostalCode = "postalCode",
|
|
1115
|
+
DeliverTo = "deliverTo",
|
|
1116
|
+
PickupAt = "pickupAt",
|
|
1117
|
+
Note = "note",
|
|
1118
|
+
AcceptTerms = "acceptTerms",
|
|
1119
|
+
PlaceOrder = "placeOrder",
|
|
1120
|
+
PlaceNote = "placeNote",
|
|
1121
|
+
OrderSummary = "orderSummary",
|
|
1122
|
+
Subtotal = "subtotal",
|
|
1123
|
+
Delivery = "delivery",
|
|
1124
|
+
DeliveryLater = "deliveryLater",
|
|
1125
|
+
Free = "free",
|
|
1126
|
+
Total = "total",
|
|
1127
|
+
IncludesVat = "includesVat",
|
|
1128
|
+
Quantity = "quantity",
|
|
1129
|
+
EmptyBag = "emptyBag",
|
|
1130
|
+
BackToShop = "backToShop",
|
|
1131
|
+
Closed = "closed",
|
|
1132
|
+
ThankYou = "thankYou",
|
|
1133
|
+
ThankYouNamed = "thankYouNamed",
|
|
1134
|
+
OrderSent = "orderSent",
|
|
1135
|
+
OrderNumber = "orderNumber",
|
|
1136
|
+
HowToPay = "howToPay",
|
|
1137
|
+
PaidWith = "paidWith",
|
|
1138
|
+
BusinessNumber = "businessNumber",
|
|
1139
|
+
Working = "working",
|
|
1140
|
+
StepOf = "stepOf",
|
|
1141
|
+
OrderMissing = "orderMissing",
|
|
1142
|
+
Legal = "legal"
|
|
1143
|
+
}
|
|
1144
|
+
/** `{name}`, `{n}`, `{of}`, `{amount}`, `{percent}`, `{number}`, `{email}`, `{total}`, `{place}` are filled by `checkoutWord`. */
|
|
1145
|
+
declare const CHECKOUT_WORDS: Readonly<Record<CheckoutWord, CommerceLabel>>;
|
|
1146
|
+
declare function checkoutWord(word: CheckoutWord, lang: string | null | undefined, fill?: Readonly<Record<string, string | number>>): string;
|
|
1147
|
+
/** Where on the checkout a refusal is said. */
|
|
1148
|
+
declare enum CheckoutSlot {
|
|
1149
|
+
Email = "email",
|
|
1150
|
+
Name = "name",
|
|
1151
|
+
Phone = "phone",
|
|
1152
|
+
Company = "company",
|
|
1153
|
+
Delivery = "delivery",
|
|
1154
|
+
Address = "address",
|
|
1155
|
+
Payment = "payment",
|
|
1156
|
+
Terms = "terms",
|
|
1157
|
+
/** The order summary: the bag itself changed. */
|
|
1158
|
+
Cart = "cart",
|
|
1159
|
+
/** The whole page: closed, busy, unreachable. */
|
|
1160
|
+
Page = "page"
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Every code a buyer's checkout can hear from iox-cms (`CommerceErrorCode`, the checkout's own refusals and
|
|
1164
|
+
* commerce-core's `OrderSnapshotRefusal`), plus `network` for no answer at all.
|
|
1165
|
+
*/
|
|
1166
|
+
declare enum SiteRefusalCode {
|
|
1167
|
+
InvalidBody = "invalid-body",
|
|
1168
|
+
InvalidEmail = "invalid-email",
|
|
1169
|
+
EmailRequired = "email-required",
|
|
1170
|
+
NameRequired = "name-required",
|
|
1171
|
+
PhoneRequired = "phone-required",
|
|
1172
|
+
CompanyRequired = "company-required",
|
|
1173
|
+
InvalidAddress = "invalid-address",
|
|
1174
|
+
AddressRequired = "address-required",
|
|
1175
|
+
AddressCountry = "address-country",
|
|
1176
|
+
UnknownShippingMethod = "unknown-shipping-method",
|
|
1177
|
+
ShippingNotChosen = "shipping-not-chosen",
|
|
1178
|
+
UnknownPaymentMethod = "unknown-payment-method",
|
|
1179
|
+
PaymentNotChosen = "payment-not-chosen",
|
|
1180
|
+
PaymentMethodUnusable = "payment-method-unusable",
|
|
1181
|
+
TermsNotAccepted = "terms-not-accepted",
|
|
1182
|
+
NoCart = "no-cart",
|
|
1183
|
+
EmptyCart = "empty-cart",
|
|
1184
|
+
NoCheckout = "no-checkout",
|
|
1185
|
+
CartChanged = "cart-changed",
|
|
1186
|
+
OutOfStock = "out-of-stock",
|
|
1187
|
+
OrderChanged = "order-changed",
|
|
1188
|
+
CheckoutClosed = "checkout-closed",
|
|
1189
|
+
ShopNotInPlan = "shop-not-in-plan",
|
|
1190
|
+
ShopPlanUnknown = "shop-plan-unknown",
|
|
1191
|
+
RateLimited = "rate-limited",
|
|
1192
|
+
Busy = "busy",
|
|
1193
|
+
UnknownOrder = "unknown-order",
|
|
1194
|
+
UnknownSite = "unknown-site",
|
|
1195
|
+
Network = "network"
|
|
1196
|
+
}
|
|
1197
|
+
interface RefusalRule {
|
|
1198
|
+
readonly slot: CheckoutSlot;
|
|
1199
|
+
readonly label: CommerceLabel;
|
|
1200
|
+
}
|
|
1201
|
+
declare const SITE_REFUSALS: Readonly<Record<SiteRefusalCode, RefusalRule>>;
|
|
1202
|
+
/** Each refusal of a failed call, on its slot, in the buyer's words. */
|
|
1203
|
+
interface SiteRefusal {
|
|
1204
|
+
code: string;
|
|
1205
|
+
slot: CheckoutSlot;
|
|
1206
|
+
words: string;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* A refused call's body (`{ statusCode, code, message, refusals? }`) as sentences: `order-refused` says each of its
|
|
1210
|
+
* `refusals` on its own field; any other code is one sentence; no body at all is `network`. `message` is a log line
|
|
1211
|
+
* and is never shown. One sentence per slot (the first wins).
|
|
1212
|
+
*/
|
|
1213
|
+
declare function siteRefusalsOf(body: unknown, lang: string | null | undefined): SiteRefusal[];
|
|
1214
|
+
|
|
1215
|
+
declare const looksLikeEmail: (value: unknown) => boolean;
|
|
1216
|
+
/** A phone a person can be called on: 7–15 digits once spaces, dashes, brackets and a leading + are dropped. */
|
|
1217
|
+
declare const looksLikePhone: (value: unknown) => boolean;
|
|
1218
|
+
|
|
1219
|
+
export { Availability, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CurrencyCode, DEFAULT_MONEY_LOCALE, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PaymentChannel, PaymentField, PaymentMethodKind, PaymentProvider, QuantityStep, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteRefusalCode, StockEffect, StockHold, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, furthestStep, includedVat, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isStorefrontProduct, isVatPercent, labelIn, looksLikeEmail, looksLikePhone, majorToMinor, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, openingOrderState, optionValueStates, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodProblems, paymentMethodReady, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, reservationExpiresAt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteRefusalsOf, stepQuantity, stockEffect, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
|
|
1220
|
+
export type { AddToCartRequest, BusinessIdentity, Cart, CartIssue, CartLine, CartTransport, CartView, CartViewLine, CatalogEntry, CheckoutFieldModes, CheckoutGateFacts, CheckoutGateRefusal, CheckoutGateResult, CommerceLabel, Money, OptionState, OptionValueState, OrderBuyer, OrderMove, OrderSnapshot, OrderSnapshotLine, OrderSnapshotResult, OrderTransition, PaymentMethodConfig, PostalAddress, PricedCart, PricedLine, PricingChoice, ProductOption, ProductVariantView, QuantityBounds, ShippingCart, ShippingGoods, ShippingMethod, ShippingQuote, SimulatedCartTransport, SiteBuyerOrder, SiteCartView, SiteCheckoutContact, SiteCheckoutOptions, SiteCheckoutView, SiteLegalLink, SitePaymentOption, SitePlacedOrder, SiteRefusal, SiteShippingMethod, SiteShippingOption, StorefrontProduct, StorefrontVariant, StudioCommerce, VariantChoice, VariantSlot };
|
|
@@ -547,6 +547,28 @@ function availableShippingMethods(methods, pricedCart) {
|
|
|
547
547
|
lineCount: pricedCart.lines.length,
|
|
548
548
|
});
|
|
549
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* What the goods still lack before a free-over method delivers free (the drawer's "Add ₪X more for free delivery"):
|
|
552
|
+
* the smallest gap over the methods offered, null when nothing ships, when no method is free-over, or when one already
|
|
553
|
+
* is free. `methods` are the ready ones (the checkout's options answer only those).
|
|
554
|
+
*/
|
|
555
|
+
function freeShippingRemaining(methods, cart) {
|
|
556
|
+
if (!cart.lines.length || !cart.requiresShipping)
|
|
557
|
+
return null;
|
|
558
|
+
const goods = subtractMoney(cart.subtotal, cart.discount);
|
|
559
|
+
let gap = null;
|
|
560
|
+
for (const method of Array.isArray(methods) ? methods : []) {
|
|
561
|
+
const over = method.kind === ShippingMethodKind.FreeOver ? method.freeOver : null;
|
|
562
|
+
if (!isMoney(over) || over.currency !== cart.currency)
|
|
563
|
+
continue;
|
|
564
|
+
const left = over.amount - goods.amount;
|
|
565
|
+
if (left <= 0)
|
|
566
|
+
return null;
|
|
567
|
+
if (!gap || left < gap.amount)
|
|
568
|
+
gap = money(left, cart.currency);
|
|
569
|
+
}
|
|
570
|
+
return gap;
|
|
571
|
+
}
|
|
550
572
|
|
|
551
573
|
var CartIssueCode;
|
|
552
574
|
(function (CartIssueCode) {
|
|
@@ -1539,6 +1561,19 @@ function productInScope(rowItem, data) {
|
|
|
1539
1561
|
return value;
|
|
1540
1562
|
return null;
|
|
1541
1563
|
}
|
|
1564
|
+
/**
|
|
1565
|
+
* The `$variant` slot for a product — the SAME value the shop runtime publishes on the canvas and the live site, and
|
|
1566
|
+
* the engine seeds during SSR (so the raw HTML already shows the price). `choice` defaults to the first sellable one.
|
|
1567
|
+
*/
|
|
1568
|
+
function variantSlotOf(product, choice, quantity = 1) {
|
|
1569
|
+
if (!product)
|
|
1570
|
+
return null;
|
|
1571
|
+
const options = productOptions(product);
|
|
1572
|
+
const views = productVariants(product);
|
|
1573
|
+
const pick = choice ?? defaultChoice(options, views);
|
|
1574
|
+
const variant = options.length ? findVariant(options, views, pick) : views[0] ?? null;
|
|
1575
|
+
return variant ? { ...variant, productId: product._id, words: variantWords(variant.choice, options), quantity } : null;
|
|
1576
|
+
}
|
|
1542
1577
|
|
|
1543
1578
|
/**
|
|
1544
1579
|
* The quantity a buyer may ask for — the stepper on a product page and on every cart line (commerce plan §3i). Whole
|
|
@@ -1827,6 +1862,282 @@ const SAMPLE_STUDIO = Object.freeze({ currency: CurrencyCode.ILS, vatPercent: 18
|
|
|
1827
1862
|
/** The cart the canvas starts with: one sample line, so the drawer has a line to design. */
|
|
1828
1863
|
const SAMPLE_CART_LINE = Object.freeze({ productId: 'sample-vase', variantId: 'sample-sand-32cm', quantity: 1 });
|
|
1829
1864
|
|
|
1865
|
+
/**
|
|
1866
|
+
* The fixed checkout (C-D3) and the order page as a SITE reads them over iox-cms's public routes (`shop.md` "E1 site
|
|
1867
|
+
* API"): the routes, the answers' shapes, the words, and how a refusal's `code` becomes a sentence on the field it is
|
|
1868
|
+
* about. The engine renders; iox-cms prices (trap T1) — nothing here computes a total.
|
|
1869
|
+
*/
|
|
1870
|
+
var SiteCommerceRoute;
|
|
1871
|
+
(function (SiteCommerceRoute) {
|
|
1872
|
+
SiteCommerceRoute["Cart"] = "cart";
|
|
1873
|
+
SiteCommerceRoute["CartLines"] = "cart/lines";
|
|
1874
|
+
SiteCommerceRoute["CheckoutOptions"] = "checkout/options";
|
|
1875
|
+
SiteCommerceRoute["Checkout"] = "checkout";
|
|
1876
|
+
SiteCommerceRoute["CheckoutPlace"] = "checkout/place";
|
|
1877
|
+
SiteCommerceRoute["Order"] = "order";
|
|
1878
|
+
})(SiteCommerceRoute || (SiteCommerceRoute = {}));
|
|
1879
|
+
/** A public commerce route of one org, ROOT-relative (the same rule as `cartEndpointPath`). */
|
|
1880
|
+
function siteCommercePath(orgId, route, id) {
|
|
1881
|
+
const base = `/api/site/${encodeURIComponent(orgId)}/${route}`;
|
|
1882
|
+
return id ? `${base}/${encodeURIComponent(id)}` : base;
|
|
1883
|
+
}
|
|
1884
|
+
/** The cart cookie iox-cms sets for one org (httpOnly — a site script never reads it; SSR forwards it). */
|
|
1885
|
+
const CART_COOKIE_PREFIX = 'iox_cart_';
|
|
1886
|
+
function cartCookieName(orgId) {
|
|
1887
|
+
return `${CART_COOKIE_PREFIX}${orgId}`;
|
|
1888
|
+
}
|
|
1889
|
+
/** The order page under the checkout: `/<orgLabel>/checkout/order/<token>`. */
|
|
1890
|
+
const ORDER_PATH = 'order';
|
|
1891
|
+
function orderHref(orgLabel, token) {
|
|
1892
|
+
const label = String(orgLabel ?? '').replace(/^\/+|\/+$/g, '');
|
|
1893
|
+
const tail = `checkout/${ORDER_PATH}/${encodeURIComponent(token)}`;
|
|
1894
|
+
return label ? `/${encodeURIComponent(label)}/${tail}` : `/${tail}`;
|
|
1895
|
+
}
|
|
1896
|
+
// ── the answers ────────────────────────────────────────────────────────────────────────────────
|
|
1897
|
+
var CheckoutFieldMode;
|
|
1898
|
+
(function (CheckoutFieldMode) {
|
|
1899
|
+
CheckoutFieldMode["Hidden"] = "hidden";
|
|
1900
|
+
CheckoutFieldMode["Optional"] = "optional";
|
|
1901
|
+
CheckoutFieldMode["Required"] = "required";
|
|
1902
|
+
})(CheckoutFieldMode || (CheckoutFieldMode = {}));
|
|
1903
|
+
/** The contact fields an owner may hide, offer or require. */
|
|
1904
|
+
var CheckoutAskedField;
|
|
1905
|
+
(function (CheckoutAskedField) {
|
|
1906
|
+
CheckoutAskedField["Phone"] = "phone";
|
|
1907
|
+
CheckoutAskedField["Company"] = "company";
|
|
1908
|
+
CheckoutAskedField["Note"] = "note";
|
|
1909
|
+
})(CheckoutAskedField || (CheckoutAskedField = {}));
|
|
1910
|
+
// ── the step a visitor is on ──────────────────────────────────────────────────────────────────
|
|
1911
|
+
/**
|
|
1912
|
+
* The step to SHOW: no checkout yet is Contact; then the first step still missing what it needs — a delivery chosen
|
|
1913
|
+
* (with an address when it delivers), then a payment. A step already passed stays open only when the buyer asks.
|
|
1914
|
+
*/
|
|
1915
|
+
function currentCheckoutStep(view) {
|
|
1916
|
+
if (!view)
|
|
1917
|
+
return CheckoutStep.Contact;
|
|
1918
|
+
const option = view.delivery ? view.shippingOptions.find(o => o.methodId === view.delivery.methodId) : undefined;
|
|
1919
|
+
if (!option || (option.needsAddress && !view.delivery?.address))
|
|
1920
|
+
return CheckoutStep.Delivery;
|
|
1921
|
+
return CheckoutStep.Payment;
|
|
1922
|
+
}
|
|
1923
|
+
/** The steps the stepper names (Paid is the order page, never a step a buyer fills). */
|
|
1924
|
+
const CHECKOUT_FORM_STEPS = Object.freeze([CheckoutStep.Contact, CheckoutStep.Delivery, CheckoutStep.Payment]);
|
|
1925
|
+
function fieldAsked(fields, field) {
|
|
1926
|
+
return (fields?.[field] ?? CheckoutFieldMode.Hidden) !== CheckoutFieldMode.Hidden;
|
|
1927
|
+
}
|
|
1928
|
+
function fieldRequired(fields, field) {
|
|
1929
|
+
return fields?.[field] === CheckoutFieldMode.Required;
|
|
1930
|
+
}
|
|
1931
|
+
/** One line of a postal address as a buyer reads it. */
|
|
1932
|
+
function addressLine(address) {
|
|
1933
|
+
if (!address)
|
|
1934
|
+
return '';
|
|
1935
|
+
return [address.line1, address.line2, [address.postalCode, address.city].filter(Boolean).join(' ')].filter(part => !!part && String(part).trim()).join(', ');
|
|
1936
|
+
}
|
|
1937
|
+
// ── the words ─────────────────────────────────────────────────────────────────────────────────
|
|
1938
|
+
var CheckoutWord;
|
|
1939
|
+
(function (CheckoutWord) {
|
|
1940
|
+
CheckoutWord["SecureCheckout"] = "secureCheckout";
|
|
1941
|
+
CheckoutWord["Email"] = "email";
|
|
1942
|
+
CheckoutWord["Name"] = "name";
|
|
1943
|
+
CheckoutWord["Phone"] = "phone";
|
|
1944
|
+
CheckoutWord["Company"] = "company";
|
|
1945
|
+
CheckoutWord["Optional"] = "optional";
|
|
1946
|
+
CheckoutWord["ContinueToDelivery"] = "continueToDelivery";
|
|
1947
|
+
CheckoutWord["ContinueToPayment"] = "continueToPayment";
|
|
1948
|
+
CheckoutWord["Change"] = "change";
|
|
1949
|
+
CheckoutWord["Street"] = "street";
|
|
1950
|
+
CheckoutWord["StreetMore"] = "streetMore";
|
|
1951
|
+
CheckoutWord["City"] = "city";
|
|
1952
|
+
CheckoutWord["PostalCode"] = "postalCode";
|
|
1953
|
+
CheckoutWord["DeliverTo"] = "deliverTo";
|
|
1954
|
+
CheckoutWord["PickupAt"] = "pickupAt";
|
|
1955
|
+
CheckoutWord["Note"] = "note";
|
|
1956
|
+
CheckoutWord["AcceptTerms"] = "acceptTerms";
|
|
1957
|
+
CheckoutWord["PlaceOrder"] = "placeOrder";
|
|
1958
|
+
CheckoutWord["PlaceNote"] = "placeNote";
|
|
1959
|
+
CheckoutWord["OrderSummary"] = "orderSummary";
|
|
1960
|
+
CheckoutWord["Subtotal"] = "subtotal";
|
|
1961
|
+
CheckoutWord["Delivery"] = "delivery";
|
|
1962
|
+
CheckoutWord["DeliveryLater"] = "deliveryLater";
|
|
1963
|
+
CheckoutWord["Free"] = "free";
|
|
1964
|
+
CheckoutWord["Total"] = "total";
|
|
1965
|
+
CheckoutWord["IncludesVat"] = "includesVat";
|
|
1966
|
+
CheckoutWord["Quantity"] = "quantity";
|
|
1967
|
+
CheckoutWord["EmptyBag"] = "emptyBag";
|
|
1968
|
+
CheckoutWord["BackToShop"] = "backToShop";
|
|
1969
|
+
CheckoutWord["Closed"] = "closed";
|
|
1970
|
+
CheckoutWord["ThankYou"] = "thankYou";
|
|
1971
|
+
CheckoutWord["ThankYouNamed"] = "thankYouNamed";
|
|
1972
|
+
CheckoutWord["OrderSent"] = "orderSent";
|
|
1973
|
+
CheckoutWord["OrderNumber"] = "orderNumber";
|
|
1974
|
+
CheckoutWord["HowToPay"] = "howToPay";
|
|
1975
|
+
CheckoutWord["PaidWith"] = "paidWith";
|
|
1976
|
+
CheckoutWord["BusinessNumber"] = "businessNumber";
|
|
1977
|
+
CheckoutWord["Working"] = "working";
|
|
1978
|
+
CheckoutWord["StepOf"] = "stepOf";
|
|
1979
|
+
CheckoutWord["OrderMissing"] = "orderMissing";
|
|
1980
|
+
CheckoutWord["Legal"] = "legal";
|
|
1981
|
+
})(CheckoutWord || (CheckoutWord = {}));
|
|
1982
|
+
/** `{name}`, `{n}`, `{of}`, `{amount}`, `{percent}`, `{number}`, `{email}`, `{total}`, `{place}` are filled by `checkoutWord`. */
|
|
1983
|
+
const CHECKOUT_WORDS = Object.freeze({
|
|
1984
|
+
[CheckoutWord.SecureCheckout]: { en: 'Secure checkout', he: 'תשלום מאובטח' },
|
|
1985
|
+
[CheckoutWord.Email]: { en: 'Email', he: 'אימייל' },
|
|
1986
|
+
[CheckoutWord.Name]: { en: 'Full name', he: 'שם מלא' },
|
|
1987
|
+
[CheckoutWord.Phone]: { en: 'Phone', he: 'טלפון' },
|
|
1988
|
+
[CheckoutWord.Company]: { en: 'Company', he: 'חברה' },
|
|
1989
|
+
[CheckoutWord.Optional]: { en: 'Optional', he: 'לא חובה' },
|
|
1990
|
+
[CheckoutWord.ContinueToDelivery]: { en: 'Continue to delivery', he: 'המשך למשלוח' },
|
|
1991
|
+
[CheckoutWord.ContinueToPayment]: { en: 'Continue to payment', he: 'המשך לתשלום' },
|
|
1992
|
+
[CheckoutWord.Change]: { en: 'Change', he: 'שינוי' },
|
|
1993
|
+
[CheckoutWord.Street]: { en: 'Street and number', he: 'רחוב ומספר' },
|
|
1994
|
+
[CheckoutWord.StreetMore]: { en: 'Apartment, floor', he: 'דירה, קומה' },
|
|
1995
|
+
[CheckoutWord.City]: { en: 'City', he: 'עיר' },
|
|
1996
|
+
[CheckoutWord.PostalCode]: { en: 'Postal code', he: 'מיקוד' },
|
|
1997
|
+
[CheckoutWord.DeliverTo]: { en: 'To {place}', he: 'אל {place}' },
|
|
1998
|
+
[CheckoutWord.PickupAt]: { en: 'Pickup at {place}', he: 'איסוף מ{place}' },
|
|
1999
|
+
[CheckoutWord.Note]: { en: 'A note for the seller', he: 'הערה למוכר' },
|
|
2000
|
+
[CheckoutWord.AcceptTerms]: { en: 'I accept the', he: 'אני מאשר/ת את' },
|
|
2001
|
+
[CheckoutWord.PlaceOrder]: { en: 'Place order · {total}', he: 'ביצוע הזמנה · {total}' },
|
|
2002
|
+
[CheckoutWord.PlaceNote]: { en: 'How to pay is on the next page.', he: 'פרטי התשלום יופיעו בעמוד הבא.' },
|
|
2003
|
+
[CheckoutWord.OrderSummary]: { en: 'Order summary', he: 'סיכום הזמנה' },
|
|
2004
|
+
[CheckoutWord.Subtotal]: { en: 'Subtotal', he: 'סכום ביניים' },
|
|
2005
|
+
[CheckoutWord.Delivery]: { en: 'Delivery', he: 'משלוח' },
|
|
2006
|
+
[CheckoutWord.DeliveryLater]: { en: 'Chosen next', he: 'ייבחר בהמשך' },
|
|
2007
|
+
[CheckoutWord.Free]: { en: 'Free', he: 'חינם' },
|
|
2008
|
+
[CheckoutWord.Total]: { en: 'Total', he: 'סה״כ' },
|
|
2009
|
+
[CheckoutWord.IncludesVat]: { en: 'Includes VAT {percent}% · {amount}', he: 'כולל מע״מ {percent}% · {amount}' },
|
|
2010
|
+
[CheckoutWord.Quantity]: { en: 'Qty {n}', he: 'כמות {n}' },
|
|
2011
|
+
[CheckoutWord.EmptyBag]: { en: 'Your bag is empty.', he: 'הסל שלך ריק.' },
|
|
2012
|
+
[CheckoutWord.BackToShop]: { en: 'Back to the shop', he: 'חזרה לחנות' },
|
|
2013
|
+
[CheckoutWord.Closed]: { en: 'The shop is not taking orders right now.', he: 'החנות לא מקבלת הזמנות כרגע.' },
|
|
2014
|
+
[CheckoutWord.ThankYou]: { en: 'Thank you! Your order is in.', he: 'תודה! ההזמנה התקבלה' },
|
|
2015
|
+
[CheckoutWord.ThankYouNamed]: { en: 'Thank you, {name}! Your order is in.', he: 'תודה, {name}! ההזמנה התקבלה' },
|
|
2016
|
+
[CheckoutWord.OrderSent]: { en: 'Order #{number} · a confirmation was sent to {email}', he: 'הזמנה #{number} · אישור נשלח ל־{email}' },
|
|
2017
|
+
[CheckoutWord.OrderNumber]: { en: 'Order #{number}', he: 'הזמנה #{number}' },
|
|
2018
|
+
[CheckoutWord.HowToPay]: { en: 'How to pay', he: 'איך משלמים' },
|
|
2019
|
+
[CheckoutWord.PaidWith]: { en: 'Payment', he: 'תשלום' },
|
|
2020
|
+
[CheckoutWord.BusinessNumber]: { en: 'Business no. {number}', he: 'ע.מ {number}' },
|
|
2021
|
+
[CheckoutWord.Working]: { en: 'One moment…', he: 'רגע…' },
|
|
2022
|
+
[CheckoutWord.StepOf]: { en: 'Step {n} of {of}', he: 'שלב {n} מתוך {of}' },
|
|
2023
|
+
[CheckoutWord.OrderMissing]: { en: 'We could not find this order.', he: 'לא מצאנו את ההזמנה הזו.' },
|
|
2024
|
+
[CheckoutWord.Legal]: { en: 'Policies', he: 'מדיניות' },
|
|
2025
|
+
});
|
|
2026
|
+
function checkoutWord(word, lang, fill = {}) {
|
|
2027
|
+
return labelIn(CHECKOUT_WORDS[word], lang).replace(/\{(\w+)\}/g, (all, key) => (key in fill ? String(fill[key]) : all));
|
|
2028
|
+
}
|
|
2029
|
+
// ── a refusal, said on its field ─────────────────────────────────────────────────────────────
|
|
2030
|
+
/** Where on the checkout a refusal is said. */
|
|
2031
|
+
var CheckoutSlot;
|
|
2032
|
+
(function (CheckoutSlot) {
|
|
2033
|
+
CheckoutSlot["Email"] = "email";
|
|
2034
|
+
CheckoutSlot["Name"] = "name";
|
|
2035
|
+
CheckoutSlot["Phone"] = "phone";
|
|
2036
|
+
CheckoutSlot["Company"] = "company";
|
|
2037
|
+
CheckoutSlot["Delivery"] = "delivery";
|
|
2038
|
+
CheckoutSlot["Address"] = "address";
|
|
2039
|
+
CheckoutSlot["Payment"] = "payment";
|
|
2040
|
+
CheckoutSlot["Terms"] = "terms";
|
|
2041
|
+
/** The order summary: the bag itself changed. */
|
|
2042
|
+
CheckoutSlot["Cart"] = "cart";
|
|
2043
|
+
/** The whole page: closed, busy, unreachable. */
|
|
2044
|
+
CheckoutSlot["Page"] = "page";
|
|
2045
|
+
})(CheckoutSlot || (CheckoutSlot = {}));
|
|
2046
|
+
/**
|
|
2047
|
+
* Every code a buyer's checkout can hear from iox-cms (`CommerceErrorCode`, the checkout's own refusals and
|
|
2048
|
+
* commerce-core's `OrderSnapshotRefusal`), plus `network` for no answer at all.
|
|
2049
|
+
*/
|
|
2050
|
+
var SiteRefusalCode;
|
|
2051
|
+
(function (SiteRefusalCode) {
|
|
2052
|
+
SiteRefusalCode["InvalidBody"] = "invalid-body";
|
|
2053
|
+
SiteRefusalCode["InvalidEmail"] = "invalid-email";
|
|
2054
|
+
SiteRefusalCode["EmailRequired"] = "email-required";
|
|
2055
|
+
SiteRefusalCode["NameRequired"] = "name-required";
|
|
2056
|
+
SiteRefusalCode["PhoneRequired"] = "phone-required";
|
|
2057
|
+
SiteRefusalCode["CompanyRequired"] = "company-required";
|
|
2058
|
+
SiteRefusalCode["InvalidAddress"] = "invalid-address";
|
|
2059
|
+
SiteRefusalCode["AddressRequired"] = "address-required";
|
|
2060
|
+
SiteRefusalCode["AddressCountry"] = "address-country";
|
|
2061
|
+
SiteRefusalCode["UnknownShippingMethod"] = "unknown-shipping-method";
|
|
2062
|
+
SiteRefusalCode["ShippingNotChosen"] = "shipping-not-chosen";
|
|
2063
|
+
SiteRefusalCode["UnknownPaymentMethod"] = "unknown-payment-method";
|
|
2064
|
+
SiteRefusalCode["PaymentNotChosen"] = "payment-not-chosen";
|
|
2065
|
+
SiteRefusalCode["PaymentMethodUnusable"] = "payment-method-unusable";
|
|
2066
|
+
SiteRefusalCode["TermsNotAccepted"] = "terms-not-accepted";
|
|
2067
|
+
SiteRefusalCode["NoCart"] = "no-cart";
|
|
2068
|
+
SiteRefusalCode["EmptyCart"] = "empty-cart";
|
|
2069
|
+
SiteRefusalCode["NoCheckout"] = "no-checkout";
|
|
2070
|
+
SiteRefusalCode["CartChanged"] = "cart-changed";
|
|
2071
|
+
SiteRefusalCode["OutOfStock"] = "out-of-stock";
|
|
2072
|
+
SiteRefusalCode["OrderChanged"] = "order-changed";
|
|
2073
|
+
SiteRefusalCode["CheckoutClosed"] = "checkout-closed";
|
|
2074
|
+
SiteRefusalCode["ShopNotInPlan"] = "shop-not-in-plan";
|
|
2075
|
+
SiteRefusalCode["ShopPlanUnknown"] = "shop-plan-unknown";
|
|
2076
|
+
SiteRefusalCode["RateLimited"] = "rate-limited";
|
|
2077
|
+
SiteRefusalCode["Busy"] = "busy";
|
|
2078
|
+
SiteRefusalCode["UnknownOrder"] = "unknown-order";
|
|
2079
|
+
SiteRefusalCode["UnknownSite"] = "unknown-site";
|
|
2080
|
+
SiteRefusalCode["Network"] = "network";
|
|
2081
|
+
})(SiteRefusalCode || (SiteRefusalCode = {}));
|
|
2082
|
+
const ENTER_EMAIL = { en: 'Enter an email address, like name@example.com.', he: 'הקלידו כתובת אימייל, למשל name@example.com.' };
|
|
2083
|
+
const ENTER_ADDRESS = { en: 'Enter the street, the number and the city.', he: 'הקלידו רחוב, מספר ועיר.' };
|
|
2084
|
+
const CHOOSE_DELIVERY = { en: 'Choose how to get your order.', he: 'בחרו איך לקבל את ההזמנה.' };
|
|
2085
|
+
const CHOOSE_PAYMENT = { en: 'Choose how to pay.', he: 'בחרו איך לשלם.' };
|
|
2086
|
+
const BAG_EMPTY = { en: 'Your bag is empty.', he: 'הסל שלך ריק.' };
|
|
2087
|
+
const CLOSED = { en: 'The shop is not taking orders right now.', he: 'החנות לא מקבלת הזמנות כרגע.' };
|
|
2088
|
+
const TRY_AGAIN = { en: 'The shop is busy. Try again in a moment.', he: 'החנות עמוסה. נסו שוב בעוד רגע.' };
|
|
2089
|
+
const SITE_REFUSALS = Object.freeze({
|
|
2090
|
+
[SiteRefusalCode.InvalidBody]: { slot: CheckoutSlot.Page, label: { en: 'Check the details and try again.', he: 'בדקו את הפרטים ונסו שוב.' } },
|
|
2091
|
+
[SiteRefusalCode.InvalidEmail]: { slot: CheckoutSlot.Email, label: ENTER_EMAIL },
|
|
2092
|
+
[SiteRefusalCode.EmailRequired]: { slot: CheckoutSlot.Email, label: ENTER_EMAIL },
|
|
2093
|
+
[SiteRefusalCode.NameRequired]: { slot: CheckoutSlot.Name, label: { en: 'Enter your name.', he: 'הקלידו את שמכם.' } },
|
|
2094
|
+
[SiteRefusalCode.PhoneRequired]: { slot: CheckoutSlot.Phone, label: { en: 'Enter a phone number.', he: 'הקלידו מספר טלפון.' } },
|
|
2095
|
+
[SiteRefusalCode.CompanyRequired]: { slot: CheckoutSlot.Company, label: { en: 'Enter the company name.', he: 'הקלידו את שם החברה.' } },
|
|
2096
|
+
[SiteRefusalCode.InvalidAddress]: { slot: CheckoutSlot.Address, label: ENTER_ADDRESS },
|
|
2097
|
+
[SiteRefusalCode.AddressRequired]: { slot: CheckoutSlot.Address, label: ENTER_ADDRESS },
|
|
2098
|
+
[SiteRefusalCode.AddressCountry]: { slot: CheckoutSlot.Address, label: { en: 'We do not deliver to this country.', he: 'אנחנו לא שולחים למדינה הזו.' } },
|
|
2099
|
+
[SiteRefusalCode.UnknownShippingMethod]: { slot: CheckoutSlot.Delivery, label: CHOOSE_DELIVERY },
|
|
2100
|
+
[SiteRefusalCode.ShippingNotChosen]: { slot: CheckoutSlot.Delivery, label: CHOOSE_DELIVERY },
|
|
2101
|
+
[SiteRefusalCode.UnknownPaymentMethod]: { slot: CheckoutSlot.Payment, label: CHOOSE_PAYMENT },
|
|
2102
|
+
[SiteRefusalCode.PaymentNotChosen]: { slot: CheckoutSlot.Payment, label: CHOOSE_PAYMENT },
|
|
2103
|
+
[SiteRefusalCode.PaymentMethodUnusable]: { slot: CheckoutSlot.Payment, label: { en: 'This way to pay does not fit the delivery. Choose another.', he: 'אמצעי התשלום הזה לא מתאים למשלוח. בחרו אחר.' } },
|
|
2104
|
+
[SiteRefusalCode.TermsNotAccepted]: { slot: CheckoutSlot.Terms, label: { en: 'Accept the terms to place the order.', he: 'כדי להזמין יש לאשר את התנאים.' } },
|
|
2105
|
+
[SiteRefusalCode.NoCart]: { slot: CheckoutSlot.Cart, label: BAG_EMPTY },
|
|
2106
|
+
[SiteRefusalCode.EmptyCart]: { slot: CheckoutSlot.Cart, label: BAG_EMPTY },
|
|
2107
|
+
[SiteRefusalCode.NoCheckout]: { slot: CheckoutSlot.Email, label: { en: 'Start with your email.', he: 'התחילו באימייל.' } },
|
|
2108
|
+
[SiteRefusalCode.CartChanged]: { slot: CheckoutSlot.Cart, label: { en: 'Your bag changed. Check it, then place the order.', he: 'הסל השתנה. בדקו אותו ואז הזמינו.' } },
|
|
2109
|
+
[SiteRefusalCode.OutOfStock]: { slot: CheckoutSlot.Cart, label: { en: 'Something in your bag just sold out.', he: 'משהו בסל אזל הרגע מהמלאי.' } },
|
|
2110
|
+
[SiteRefusalCode.OrderChanged]: { slot: CheckoutSlot.Page, label: { en: 'This order was already placed.', he: 'ההזמנה הזו כבר בוצעה.' } },
|
|
2111
|
+
[SiteRefusalCode.CheckoutClosed]: { slot: CheckoutSlot.Page, label: CLOSED },
|
|
2112
|
+
[SiteRefusalCode.ShopNotInPlan]: { slot: CheckoutSlot.Page, label: CLOSED },
|
|
2113
|
+
[SiteRefusalCode.ShopPlanUnknown]: { slot: CheckoutSlot.Page, label: TRY_AGAIN },
|
|
2114
|
+
[SiteRefusalCode.RateLimited]: { slot: CheckoutSlot.Page, label: { en: 'Too many tries. Wait a minute and try again.', he: 'יותר מדי ניסיונות. המתינו דקה ונסו שוב.' } },
|
|
2115
|
+
[SiteRefusalCode.Busy]: { slot: CheckoutSlot.Page, label: TRY_AGAIN },
|
|
2116
|
+
[SiteRefusalCode.UnknownOrder]: { slot: CheckoutSlot.Page, label: { en: 'We could not find this order.', he: 'לא מצאנו את ההזמנה הזו.' } },
|
|
2117
|
+
[SiteRefusalCode.UnknownSite]: { slot: CheckoutSlot.Page, label: CLOSED },
|
|
2118
|
+
[SiteRefusalCode.Network]: { slot: CheckoutSlot.Page, label: { en: 'We could not reach the shop. Try again.', he: 'לא הצלחנו להגיע לחנות. נסו שוב.' } },
|
|
2119
|
+
});
|
|
2120
|
+
const isRefusalCode = (code) => typeof code === 'string' && Object.values(SiteRefusalCode).includes(code);
|
|
2121
|
+
const ORDER_REFUSED = 'order-refused';
|
|
2122
|
+
function refusalOf(code, lang) {
|
|
2123
|
+
const known = isRefusalCode(code) ? code : SiteRefusalCode.InvalidBody;
|
|
2124
|
+
const rule = SITE_REFUSALS[known];
|
|
2125
|
+
return { code: isRefusalCode(code) ? code : String(code ?? known), slot: rule.slot, words: labelIn(rule.label, lang) };
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* A refused call's body (`{ statusCode, code, message, refusals? }`) as sentences: `order-refused` says each of its
|
|
2129
|
+
* `refusals` on its own field; any other code is one sentence; no body at all is `network`. `message` is a log line
|
|
2130
|
+
* and is never shown. One sentence per slot (the first wins).
|
|
2131
|
+
*/
|
|
2132
|
+
function siteRefusalsOf(body, lang) {
|
|
2133
|
+
const answer = body && typeof body === 'object' ? body : null;
|
|
2134
|
+
if (!answer)
|
|
2135
|
+
return [refusalOf(SiteRefusalCode.Network, lang)];
|
|
2136
|
+
const codes = answer.code === ORDER_REFUSED && Array.isArray(answer.refusals) && answer.refusals.length ? answer.refusals : [answer.code];
|
|
2137
|
+
const seen = new Set();
|
|
2138
|
+
return codes.map(code => refusalOf(code, lang)).filter(r => !seen.has(r.slot) && !!seen.add(r.slot));
|
|
2139
|
+
}
|
|
2140
|
+
|
|
1830
2141
|
/**
|
|
1831
2142
|
* @vectoriox/iox-ui/commerce-core — the shared, FRAMEWORK-FREE core of selling (commerce plan C-D7…C-D11, C-D19).
|
|
1832
2143
|
*
|
|
@@ -1842,5 +2153,5 @@ const SAMPLE_CART_LINE = Object.freeze({ productId: 'sample-vase', variantId: 's
|
|
|
1842
2153
|
* Generated bundle index. Do not edit.
|
|
1843
2154
|
*/
|
|
1844
2155
|
|
|
1845
|
-
export { Availability, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutGateArea, CheckoutGateCode, CheckoutStep, CommerceLanguage, CurrencyCode, DEFAULT_MONEY_LOCALE, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PaymentChannel, PaymentField, PaymentMethodKind, PaymentProvider, QuantityStep, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, StockEffect, StockHold, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, availableShippingMethods, canBuy, canStep, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, chooseValue, clampQuantity, commerceLanguage, currencyExponent, defaultChoice, emptyCartView, findVariant, formatMoney, formatMoneyValue, furthestStep, includedVat, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isStorefrontProduct, isVatPercent, labelIn, majorToMinor, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, openingOrderState, optionValueStates, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodProblems, paymentMethodReady, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, reservationExpiresAt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, stepQuantity, stockEffect, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, usablePaymentMethods, variantChoiceOf, variantWords };
|
|
2156
|
+
export { Availability, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CurrencyCode, DEFAULT_MONEY_LOCALE, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PaymentChannel, PaymentField, PaymentMethodKind, PaymentProvider, QuantityStep, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteRefusalCode, StockEffect, StockHold, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, furthestStep, includedVat, isCurrencyCode, isMoney, isPaymentMethodKind, isShippingMethodKind, isStorefrontProduct, isVatPercent, labelIn, looksLikeEmail, looksLikePhone, majorToMinor, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, openingOrderState, optionValueStates, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodProblems, paymentMethodReady, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, reservationExpiresAt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteRefusalsOf, stepQuantity, stockEffect, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
|
|
1846
2157
|
//# sourceMappingURL=vectoriox-iox-ui-commerce-core.mjs.map
|