Skip to main content
This section contains practical examples for using vouchers in the checkout.

Voucher input form with maximumCount check

The input form is only displayed as long as fewer vouchers have been redeemed than allowed. As soon as the upper limit is reached, the form disappears automatically.
Error messages (e.g. “Minimum order value not reached”) are defined and rendered via components/errorAlert.htm.

Displaying the list of redeemed vouchers

A separate small form with a unique ID is output for each voucher. Valid vouchers appear in green, invalid ones in red.

Displaying all redeemed vouchers in the basket

In this example, all redeemed vouchers are shown in the basket. The customer can transparently see which codes are in the system and which one is currently being applied. Vouchers that have no effect are not added to the list and are indicated via an error message.

Free shipping method for voucher-only baskets

If a basket contains only (instant) vouchers, no physical shipping is required. For this case you can define a dedicated, always free shipping method under checkout.shippingMethod: the basicCost scale sets the cost to 0 from a subtotal of 0, and the validation shippingMethodValidation.productType with rule: deny blocks the shipping method as soon as a regular product (product type standard) is in the basket — so it can only be selected for pure voucher baskets.
The value standard in the ruleList is the value of the product type field of the products (the product data field defined as product type via content.usedFields) — not to be confused with the shipping method’s own type: "standard" parameter. Products for which the product type field is not set always pass the check.name, description and orderText refer to text snippets in this example, so the texts can be maintained per language via the text-snippet service.