> ## Documentation Index
> Fetch the complete documentation index at: https://dokumentation.websale.de/llms.txt
> Use this file to discover all available pages before exploring further.

# Voucher

> Reference for WEBSALE voucher actions used to redeem voucher codes in the basket and remove them again from the customer's current order.

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

| **Action**      | **Description**                             |
| --------------- | ------------------------------------------- |
| `VoucherAdd`    | Redeems a voucher code in the basket.       |
| `VoucherDelete` | Removes 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**

| **Name** | **Description**                  |
| -------- | -------------------------------- |
| `id`     | The voucher code to be redeemed. |

**Error codes**

| **Error code**   | **Description**                                            |
| ---------------- | ---------------------------------------------------------- |
| `missingId`      | Parameter `id` is missing.                                 |
| `invalidVoucher` | The specified voucher code is invalid or already redeemed. |

**Related modules, variables & methods**

* [\$wsVoucher](/en/frontend/referenz/module/wsvoucher)
* [\$wsVoucher.vouchers](/en/frontend/referenz/module/wsvoucher#\$wsvoucher-vouchers)
* [\$wsVoucher.totalValue](/en/frontend/referenz/module/wsvoucher#\$wsvoucher-totalvalue)

**Example** showing how a voucher code is redeemed via an input field.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ 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**

| **Name** | **Description**                      |
| -------- | ------------------------------------ |
| `id`     | The ID of the voucher to be removed. |

**Error codes**

| **Error code**     | **Description**                                                         |
| ------------------ | ----------------------------------------------------------------------- |
| `missingId`        | Parameter `id` is missing.                                              |
| `invalidVoucherId` | The specified voucher does not exist or does not belong to this basket. |

**Related modules, variables & methods**

* [\$wsVoucher](/en/frontend/referenz/module/wsvoucher)
* [\$wsVoucher.vouchers](/en/frontend/referenz/module/wsvoucher#\$wsvoucher-vouchers)
* [\$wsVoucher.totalValue](/en/frontend/referenz/module/wsvoucher#\$wsvoucher-totalvalue)

**Example** showing how all redeemed vouchers are listed and each one can be removed via a button.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ 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 }}
```
