Skip to main content
With the $wsCheckout module, you can read all data of the order process in the frontend. This includes the selected payment and shipping method, billing and delivery address, the order totals, as well as the validation and error status. This page covers reading the checkout data. Everything that changes the checkout (selecting an address, setting the payment method, triggering the order) is documented under Actions → Checkout.

Basic concept

The checkout collects the customer’s selection (payment, shipping, addresses, free fields) and continuously checks whether the order can be executed. Through $wsCheckout, you read this selection and the validation status to design the order flow and provide targeted feedback to the customer.

Validation

There are three levels of validation feedback that differ in granularity. Choose the level based on what you want to display:
  • Overall status - isValid indicates whether the order as a whole can be executed. Use it, for example, to enable or disable the “Buy” button.
  • Field state - fieldStates provides a state per field (untouched, empty, invalid, incompatible, valid). Use it, for example, to visually mark a field.
  • Specific errors - problems provides 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 exactly how to resolve the error.

Immediate errors and errors after an action

The checkout has two sources of error feedback:
  • $wsCheckout.problems.* - shown as soon as a field has been selected or left, provided that show*BeforeSubmit is set to true in the configuration. After the first purchase attempt, the errors are shown regardless of this setting.
  • actionResponse errors - originate 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 no problems.*; in those cases, actionResponse errors are filtered via show*BeforeSubmit.

Selection IDs and draft addresses

The selected* variables contain the ID of the respective selected 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 kept under a fixed system ID: draftBillAddressId or draftShippingAddressId. These IDs are always present - even if no draft exists. Whether a draft is actually present (and what data it contains) is read via the maps draftBillAddress / draftShippingAddress, which are only output in that case.

Module overview

Example / excerpt of $wsCheckout
JSON output (abbreviated)
Note: "ƒ()" 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 the elements is arbitrary.

Variables

$wsCheckout.accountType

Returns the account type: "guest" (guest), "new" (new account), or "registered" (logged in). As long as the customer has not yet chosen an account type, the value is empty (""). Evaluate it, for example, to offer a guest the option to create an account.

$wsCheckout.guestMail

Returns the email address of a guest account. Only populated for a guest order.

$wsCheckout.selectedPayment / selectedShippingMethod

Return the ID of the selected payment method or shipping method. Evaluate them to display or check the selection that was made.

$wsCheckout.selectedBillAddress / selectedShippingAddress

Return the ID of the selected billing or delivery address. You pass this ID, for example, to $wsAccount.loadAddress() to load the full address.

$wsCheckout.draftBillAddressId / draftShippingAddressId

Return the fixed system ID under which a new address that was created during the order flow and is not yet saved in the customer account (draft address) is kept — for example, 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 is actually present is checked via the maps draftBillAddress / draftShippingAddress.

$wsCheckout.draftBillAddress / draftShippingAddress

Return the data of the draft billing or draft delivery address as a map. Only present if a draft exists — so they also work as an existence check. The keys correspond to the address field names (standard fields such as firstName, lastName, street, zip, city, country, as well as additional address fields). Only fields with a non-empty value are output.
A draft address is created via the action CheckoutSetDraftAddress.

$wsCheckout.useAlternativeShippingAddress

Returns whether a delivery address different from the billing address is used.

$wsCheckout.selectedStoreId

Returns the ID of the selected store (e.g. for Click & Collect). 0 if no store is selected.

$wsCheckout.selectedPseudoCC

Returns the pseudo credit card token of the selected payment.

$wsCheckout.orderId / orderCreatedAt

Return the ID and creation time (ISO 8601) of the order. Both variables are only present once an order exists in the current session — e.g. on the order confirmation page.

$wsCheckout.customerData

Returns 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 under customer.customerDataGroup.

Field object

Example that outputs all visible field groups with their fields:

$wsCheckout.freeFields

Returns the free checkout fields (e.g. T&C checkbox, comment field). Iterate over the fields and evaluate them via their id.

Properties of a free field

$wsCheckout.isValid

Returns whether the order as a whole can be executed. This is the overall status across all fields – use it to enable or disable the “Buy” button.

$wsCheckout.isExpressCheckoutLocked

Returns 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

Return whether the respective PayPal Commerce Platform express checkout is active. Use them to display the appropriate express checkout flow.

$wsCheckout.paymentCaptchaRequired / paymentBlocked

Protection against repeated payment attempts (IP- or session-based): paymentCaptchaRequired indicates whether a captcha must be solved before the next payment attempt. paymentBlocked indicates whether further payment attempts are currently blocked.

$wsCheckout.isOrderBlockedByIneffectiveVoucher

Indicates whether the order is blocked because a redeemed voucher cannot take effect on the current basket. Use it to point the customer to the ineffective voucher.

$wsCheckout.verificationStatus / verificationStatusOptions

verificationStatus returns the verification status of the order as a number. verificationStatusOptions lists the possible statuses.

$wsCheckout.voucherAppliesPerItem

Returns whether a voucher is applied per item (instead of on the total amount).

$wsCheckout.restUntilFreeDelivery / freeShippingMethod

restUntilFreeDelivery returns the remaining amount until the free shipping threshold (0 if the threshold has been reached). The variable is only present if a free-shipping threshold can be determined for the basket. Use it for a “Only X left until free shipping” notice. 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

Returns a map with the state of each checkout field (payment, shippingMethod, billAddress, shippingAddress). Use it to mark individual fields specifically – e.g. an unfilled field neutrally, a faulty one in red.
The states build on each other. The system checks in sequence: selected (untouched) → value present (empty) → valid (invalid) → allowed in context (incompatible). Only when all checks have passed does the field count as valid. The first applicable state is returned.

$wsCheckout.problems

Returns a map with specific 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 populated when a problem is present there.

Properties of an error

Each error is an object with exactly two properties:
The error objects do not contain a descriptive error text (text) or the affected field (field). Formulate the customer-facing message in the template based on code and, if applicable, check (see example below).

Meaning of the error codes

Example that outputs the payment method errors in a customer-friendly way:
To access an individual error, use the index, e.g. $wsCheckout.problems.payment[0].code. $wsCheckout.problems does not provide errors for free checkout fields — those are evaluated via the actionResponse errors of the respective action (e.g. CheckoutSetFreeFields).

$wsCheckout.sum

Returns a map with the price information for the checkout. To display a value as a monetary amount, use the currency 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 configured for the payment method under validations are executed (see paymentValidation.* - Payment method validation) — e.g. country rules, order value limits, or exclusion when voucher products are in the basket (paymentValidation.voucherDeny). Additionally, it is checked whether the payment method is active and permitted for the customer account. If at least one rule fails, the method returns false. This is how the configured validation rules take effect in the frontend: the template hides or disables the payment method. Signature
$wsCheckout.isValidPayment(paymentId)
Return value
true / false — payment method available / not available.
Parameters Example that checks whether the payment method is available.
Example that offers all payment methods as a selection and disables those that are not available. Payment methods whose validation fails (e.g. due to paymentValidation.voucherDeny with a voucher product in the basket) are visible but not selectable.
Why the currently selected payment method is invalid can be evaluated via $wsCheckout.problems.payment; the check field there contains the name of the failed validation service.

$wsCheckout.isValidShippingMethod()

Checks whether the shipping method with the specified ID is available. All validation rules configured for the shipping method under validations 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 or disables the shipping method (same pattern as isValidPayment()). The reasons for a disabled shipping method can be output via getShippingMethodDisabledErrors(). Signature
$wsCheckout.isValidShippingMethod(shippingMethodId)
Return value
true / 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 delivery address. Signature
$wsCheckout.isValidBillAddress(addressId) · $wsCheckout.isValidShippingAddress(addressId)
Return value
bool – valid / not valid.

$wsCheckout.isPending() / isFinished()

isPending() checks whether a payment process is still pending; isFinished() checks whether the order has been completed. Use them to detect the status of an ongoing or completed order. Signature
$wsCheckout.isPending() · $wsCheckout.isFinished()
Return value
bool.

$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)
Return value
int – 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 cannot be selected. Signature
$wsCheckout.getShippingMethodDisabledErrors(shippingMethodId)
Return value
array – list of error messages.

$wsCheckout.getShippingCost()

Returns the shipping costs of a specific shipping method, even if it is not selected. The value is based on the current basket. Use it, for example, to display the shipping costs of various options in advance. Signature
$wsCheckout.getShippingCost(shippingMethodId)
Return value
float – 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)
Return value
float – discount amount for the item.

Actions

Actions that change the checkout (selecting an address, setting the payment method, triggering 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 specific problems are listed — based on code and check, since the error objects do not contain a ready-made text.
Result
For a valid order, the buy area appears; otherwise the open items per area are shown.

Totals overview

A complete totals display. The currency filter already includes the currency symbol.
Result
A breakdown of totals with correctly formatted monetary amounts.

Check T&C acceptance

Checks whether the free field agb is checked before the order is allowed.
Result
If the T&C checkbox is not checked, the notice appears.

Check the selected payment method

Result
The selected payment method is shown if it is valid.

  • Actions → Checkout – change the checkout (set selection, trigger order), since $wsCheckout itself is read-only.
  • $wsBasket – the basket on which the checkout is built; provides the items for itemVoucherDiscount().
  • $wsAccount – uses loadAddress() to load the full address for selectedBillAddress/selectedShippingAddress.
  • Checkout configuration – controls when errors are displayed via show*BeforeSubmit.