$wsCheckout module, you read all data of the order process in the frontend. This includes the selected payment and shipping method, billing and shipping address, order totals, and the validation and error status.
This page is about reading the checkout data. Everything that changes the checkout (choose an address, set a payment method, place the order) is described under Actions → Checkout.
Basic concept
The checkout collects the customer’s choices (payment, shipping, addresses, free fields) and continuously checks whether the order can be placed. Via$wsCheckout, you read this selection and the check status to shape the order flow and give the customer targeted feedback.
Validation
For the check feedback there are three levels with different granularity. Choose the level according to what you want to display:- Overall status -
isValidindicates whether the order can be placed overall. Use it, for example, to enable or disable the “Buy” button. - Field state -
fieldStatesreturns a state per field (untouched,empty,invalid,incompatible,valid). Use it, for example, to visually mark a field. - Concrete errors -
problemsreturns a list of errors per area with an error code and the name of the failed check. Use it, for example, to tell the customer how to specifically resolve the error.
Immediate errors and errors after an action
The checkout knows two sources of error feedback:$wsCheckout.problems.*- is displayed as soon as a field is selected or left, provided thatshow*BeforeSubmitis set totruein the configuration. After the first purchase attempt, the errors are displayed regardless of this setting.actionResponseerrors - come from the server response after an action. For most sections they are output unfiltered. Exception: for customer data fields and the draft address there is noproblems.*; there, theactionResponseerrors are filtered viashow*BeforeSubmit.
Selection IDs and draft addresses
Theselected* variables contain the ID of the currently chosen option (e.g. the address ID that you pass to $wsAccount.loadAddress()).
If the customer creates a new address during the order flow that is not yet saved in the customer account (draft address), it is tracked under a fixed system ID: draftBillAddressId or draftShippingAddressId. These IDs are always present - even if no draft exists. Whether a draft actually exists (and which data it contains) is read via the maps draftBillAddress / draftShippingAddress, which are only output when this is the case.
Module overview
Example / excerpt of$wsCheckout
"ƒ()" denotes a function. Conditional variables such as orderId, orderCreatedAt, restUntilFreeDelivery, freeShippingMethod, draftBillAddress, and draftShippingAddress only appear when they are set.
Variables overview
Methods overview
Templates
The checkout is freely designable and can span one or more shop pages. The order of elements is arbitrary.Variables
$wsCheckout.accountType
Outputs the account type:"guest" (guest), "new" (new account), or "registered" (registered). As long as the customer has not chosen an account type, the value is empty (""). Evaluate it to, for example, offer a guest the option to create an account.
$wsCheckout.guestMail
Outputs the email address of a guest account. Only filled for a guest order.$wsCheckout.selectedPayment / selectedShippingMethod
Output the ID of the selected payment or shipping method. Evaluate them to display or check the selection made.$wsCheckout.selectedBillAddress / selectedShippingAddress
Output the ID of the selected billing or shipping address. Pass this ID, for example, to$wsAccount.loadAddress() to load the full address.
$wsCheckout.draftBillAddressId / draftShippingAddressId
Output the fixed system ID under which a newly created address (draft address) is tracked in the order flow, which has not yet been saved in the customer account - e.g. to recognize it as the selected address in the address selection. Both IDs are always present, regardless of whether a draft exists. Whether a draft actually exists is checked via the mapsdraftBillAddress / draftShippingAddress.
$wsCheckout.draftBillAddress / draftShippingAddress
Output the data of the draft billing or draft shipping address as a map. Only present if a draft exists - which means they also serve as an existence check. The keys correspond to the address field names (standard fields such asfirstName, lastName, street, zip, city, country, as well as additional address fields). Only fields with a non-empty value are output.
$wsCheckout.useAlternativeShippingAddress
Outputs whether a shipping address different from the billing address is used.$wsCheckout.selectedStoreId
Outputs the ID of the selected store (e.g. for Click & Collect).0 if no store is selected.
$wsCheckout.selectedPseudoCC
Outputs the pseudo credit card token of the selected payment.$wsCheckout.orderId / orderCreatedAt
Output the ID and the creation time (ISO 8601) of the order. Both variables are only present as soon as an order exists in the current session - e.g. on the order confirmation page.$wsCheckout.customerData
Outputs the configured customer data fields - grouped and split by target group. Which fields are included depends on the login status: for logged-in customers the account fields, otherwise the fields stored in the order.Structure of $wsCheckout.customerData
Group object
The groups correspond to the configuration undercustomer.customerDataGroup.
Field object
Example that outputs all visible field groups with their fields:
$wsCheckout.freeFields
Outputs the free checkout fields (e.g. terms and conditions checkbox, comment field). Iterate over the fields and evaluate them via theirid.
Properties of a free field
$wsCheckout.isValid
Outputs whether the order can be placed overall. This is the overall status across all fields – use it to enable or disable the “Buy” button.$wsCheckout.isExpressCheckoutLocked
Outputs whether the express checkout is locked – e.g. after the customer has paid via PayPal and is redirected back to the shop for confirmation. Evaluate it to prevent editing of the basket in this state.$wsCheckout.isPPCExpressCheckout / isPPCApplePayExpressCheckout / isPPCGooglePayExpressCheckout
Output whether the respective express checkout of the PayPal Commerce Platform is active. Use them to render the appropriate express checkout flow.$wsCheckout.paymentCaptchaRequired / paymentBlocked
Protection against repeated payment attempts (IP- or session-based):paymentCaptchaRequired outputs whether a captcha must be solved before the next payment attempt. paymentBlocked outputs whether further payment attempts are currently blocked.
$wsCheckout.isOrderBlockedByIneffectiveVoucher
Outputs whether the order is blocked because a redeemed voucher cannot take effect on the current basket. Use it to disable the order button.ineffectiveVoucherErrors. Whether the order is blocked at all is controlled by disableOrderOnIneffectiveVoucher in the checkout configuration.
$wsCheckout.ineffectiveVoucherErrors
Outputs a list of the errors for redeemed vouchers that have no effect on the current basket. Each entry names the reason and, where assignable, the affected voucher. With this you replace a generic notice with a concrete statement. If all vouchers apply, the list is empty. Unlikeproblems, these errors already contain a ready-made text. The shop translates the text snippet stored under the configuration node checkout.voucherErrors for the respective error case.
Properties of an error
subCode and field are present so that all error objects in the frontend have the same structure. They are not currently filled here, but may receive values later. Only evaluate them if they are actually filled.Meaning of the error codes
The list may contain additional codes in the future. Therefore, provide a fallback in the template for unknown codes, for example by outputting
text.
Example that outputs the concrete reason per voucher:
For each ineffective voucher, a line appears with the voucher ID and reason. The error from the sum check appears as a line without an ID.
$wsCheckout.verificationStatus / verificationStatusOptions
verificationStatus outputs the verification status of the order as a number. verificationStatusOptions lists the possible statuses.
$wsCheckout.voucherAppliesPerItem
Outputs whether a voucher is applied per item (rather than to the total amount).$wsCheckout.restUntilFreeDelivery / freeShippingMethod
restUntilFreeDelivery outputs the remaining amount up to the threshold for free shipping (0 when the threshold is reached). The variable is only present if a free shipping threshold can be determined for the basket. Use it for a hint like “Only X more until free shipping”.
freeShippingMethod additionally contains the ID of the configured default free shipping method - but only as long as the customer has not yet chosen a shipping method and a default free shipping method is configured.
$wsCheckout.fieldStates
Outputs a map with the state of each checkout field (payment, shippingMethod, billAddress, shippingAddress). With this, you mark individual fields specifically – e.g. an unfilled field neutrally, an erroneous one in red.
The states build on each other. They are checked in order: selected (
untouched) → value present (empty) → valid (invalid) → allowed in context (incompatible). Only when all checks have passed is the field considered valid. The first matching state is output.$wsCheckout.problems
Outputs a map with concrete errors per area. The map contains exactly six areas:payment, shippingMethod, billAddress, shippingAddress, clearing, and general. Each area is a list of errors; it is filled when there is a problem there.
Properties of an error
Each error is an object with exactly two properties:Meaning of the error codes
Example that outputs the payment method errors in a customer-friendly way:
To access a single error, use the index, e.g.
$wsCheckout.problems.payment[0].code. $wsCheckout.problems does not provide errors for free checkout fields - evaluate these via the actionResponse errors of the respective action (e.g. CheckoutSetFreeFields).$wsCheckout.sum
Outputs a map with the price information for the checkout. To display as a monetary amount, use thecurrency filter – it already includes the currency symbol.
Properties of $wsCheckout.sum
Methods
$wsCheckout.isValidPayment()
Checks whether the payment method with the specified ID is available. All validation rules stored in the configuration of the payment method undervalidations are executed (see paymentValidation.* - payment method validation) - e.g. country rules, order value limits, or the exclusion for voucher products in the basket (paymentValidation.voucherDeny). Additionally, it is checked whether the payment method is active and allowed for the customer account.
If at least one rule fails, the method returns false. In this way, the configured validation rules take effect in the frontend: the template hides the payment method or disables it.
Signature$wsCheckout.isValidPayment(paymentId)
Returnstrue / false - payment method available / not available.
Parameters
Example that checks whether the payment method is available.
paymentValidation.voucherDeny for a voucher product in the basket) are visible but not selectable.
$wsCheckout.problems.payment; the check field there contains the name of the failed validation service.
$wsCheckout.hasPaymentVault()
Checks whether the logged-in customer has a link to the payment provider, based on the payment method currently chosen in the checkout. If a link exists, the order is paid directly via it and the customer does not have to go through the approval at the payment provider again. Use this method in the checkout to either display the stored payment source or to show the offer to link. The method returnsfalse in all doubtful cases: if no payment method is selected, if the selected payment method does not support linking, or if the customer is not logged in.
Signature$wsCheckout.hasPaymentVault()
Returnstrue / false - link present / not present.
Example that distinguishes between a stored link and new linking in the checkout.
For a check outside the checkout, for example on a page in the customer account where the link is managed, use the $wsAccount.hasPaymentVault() method. This method expects the payment method as a parameter.
$wsCheckout.isValidShippingMethod()
Checks whether the shipping method with the specified ID is available. All validation rules stored in the configuration of the shipping method undervalidations are executed (see shippingMethodValidation.* - shipping method validation) - e.g. country rules, order value limits, or product type restrictions.
If at least one rule fails, the method returns false. The template then hides the shipping method or disables it (same pattern as for isValidPayment()). The reasons why a shipping method is disabled can be output via getShippingMethodDisabledErrors().
Signature$wsCheckout.isValidShippingMethod(shippingMethodId)
Returnstrue / false - shipping method available / not available.
Parameters
Example that checks whether the specified shipping method is available.
$wsCheckout.isValidBillAddress() / isValidShippingAddress()
Check whether the address with the specified ID is valid as a billing or shipping address. Signature$wsCheckout.isValidBillAddress(addressId) · $wsCheckout.isValidShippingAddress(addressId)
Returnsbool – valid / not valid.
$wsCheckout.isPending() / isFinished()
isPending() checks whether a payment process is still pending, isFinished() whether the order has been completed. Use them to detect the status of an in-progress or completed order.
Signature$wsCheckout.isPending() · $wsCheckout.isFinished()
Returnsbool.
$wsCheckout.getAmountInSmallestUnit()
Returns an amount in the smallest currency unit (e.g. cents instead of euros). Useful for payment APIs that expect amounts in cents. Signature$wsCheckout.getAmountInSmallestUnit(amount)
Returnsint – amount in the smallest unit.
$wsCheckout.getShippingMethodDisabledErrors()
Returns why a shipping method is disabled. Use it to explain to the customer why a shipping method is not selectable. Signature$wsCheckout.getShippingMethodDisabledErrors(shippingMethodId)
Returnsarray – list of error messages.
$wsCheckout.getShippingCost()
Returns the shipping costs of a specific shipping method. Also when it is not selected. The value refers to the current basket. Use it, for example, to display the shipping costs of various options in advance. Signature$wsCheckout.getShippingCost(shippingMethodId)
Returnsfloat – shipping costs of the specified shipping method.
$wsCheckout.itemVoucherDiscount()
Calculates the voucher discount for a single basket item. Pass the ID of a basket entry. Signature$wsCheckout.itemVoucherDiscount(itemId)
Returnsfloat – discount amount for the item.
Actions
Actions that change the checkout (choose an address, set a payment method, place the order) are documented separately: Actions → Checkout.Examples
Check whether the order can be placed and display errors
This example combines the validation levels:If the order is valid, the “Buy” area is shown, otherwise the concrete problems are listed - based on
code and check, since the error objects do not contain a ready-made text.
For a valid order, the Buy area appears, otherwise the open items per area.
Totals overview
A complete totals display. Thecurrency filter already includes the currency symbol.
An itemized totals overview with correctly formatted monetary amounts.
Check acceptance of terms and conditions
Checks whether the free fieldagb is checked before the order is allowed.
If the terms checkbox is not checked, the notice appears.
Check the selected payment method
The selected payment method is displayed, provided it is valid.
Further links
- Actions → Checkout – change the checkout (set selection, place order), because
$wsCheckoutitself only reads. - $wsBasket – the basket that the checkout is built on; provides the items for
itemVoucherDiscount(). - $wsAccount – loads the full address for
selectedBillAddress/selectedShippingAddressvialoadAddress(). - Checkout configuration – controls with
show*BeforeSubmitwhen errors are displayed. - Error texts for ineffective vouchers – maintains the texts that
ineffectiveVoucherErrorsoutputs. - $wsVoucher – the redeemed vouchers themselves, matching the IDs from
ineffectiveVoucherErrors.
