Gift voucher

The gift voucher form is placed on the gift voucher view as a way for a user to add a gift voucher to their basket.

The form should have it's action attribute set to /gift-voucher.

All fields on the form are required. The form fields are as follows:

amount
extra_data[recipients_name]
extra_data[customers_name]
type
extra_data[message]


amount

When the gift vouchers app is installed and configured you are able to determine what values the user is able to select/enter for their gift voucher.

Either they can enter any amount they choose, can only buy a gift voucher of one (specific) amount or you can configure different values for them to choose from. The settings can be determined with the values variable.

In the example below we are using HTML macros to display the form fields:

{% if values %}
    {{ html.select('amount', values, '', 'form-control required custom-select', 'Select...') }}
{% elseif value %}
    £{{ value }}
    {{ html.input('amount', value, '', 'hidden') }}
{% else %}
    {{ html.input('amount', '', 'form-control required') }}
{% endif %}

type

When configuring the gift voucher app you can also set different 'styles' of card which can be purchased by the user. For example, a gift voucher sent by post and a gift voucher sent by email.

The different 'styles' can be outputted as in the example below.

{% for style in styles %}
    {{ style.name }} <!-- e.g. By Post -->
    {{ style.id }}
{% endfor %}

On submission of the form a special product will be added to the basket (the gift voucher product). The user will be transferred to the checkout/basket view.