Skip to main content
This section describes the available actions in the Voucher area. With these actions, voucher codes can be redeemed in the basket and removed again.

Actions overview

ActionDescription
VoucherAddRedeems a voucher code in the basket.
VoucherDeleteRemoves a redeemed voucher from the basket.

Actions

VoucherAdd

This action redeems a voucher code in the basket. Usage example
Can be used on the basket page or in the basket offcanvas, where customers can enter a voucher code and apply it directly to their order.
Parameters
NameDescription
idThe voucher code to be redeemed.
Error codes
Error codeDescription
missingIdParameter id is missing.
invalidVoucherThe specified voucher code is invalid or already redeemed.
Related modules, variables & methods Example showing how a voucher code is redeemed via an input field.
{{ var $myActionVoucherAdd = $wsActions.create("VoucherAdd") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wsact" value="{{= $myActionVoucherAdd.id }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionVoucherAdd.csrf }}">
    <input type="text" name="id" placeholder="%%VoucherCode%%">
    <button type="submit">Redeem voucher.</button>
</form>

VoucherDelete

This action removes a voucher that has already been redeemed from the basket. Usage example
Can be used on the basket page or in the basket offcanvas when customers want to remove a redeemed voucher.
Parameters
NameDescription
idThe ID of the voucher to be removed.
Error codes
Error codeDescription
missingIdParameter id is missing.
invalidVoucherIdThe specified voucher does not exist or does not belong to this basket.
Related modules, variables & methods Example showing how all redeemed vouchers are listed and each one can be removed via a button.
{{ foreach $myVoucher in $wsVoucher.vouchers }}
    {{ var $myActionVoucherDelete = $wsActions.create("VoucherDelete") }}
    <form method="post" action="{{= $wsViews.current.url() }}">
        <input type="hidden" name="wsact" value="{{= $myActionVoucherDelete.id }}">
        <input type="hidden" name="wscsrf" value="{{= $myActionVoucherDelete.csrf }}">
        <input type="hidden" name="id" value="{{= $cVoucher.id }}">
        <button type="submit">Remove voucher.</button>
    </form>
{{ /foreach }}