Product add to basket
The add to basket form is placed on the product view in order to add a product to the visitor's shopping basket.
The action attribute of the product form needs to be set to the product url, i.e. action="{{ product.url }}"
The method attribute should be
post.
The form can be submitted with a button with the attribute of type="submit".
quantity
The form must contain a field with the name quantity, e.g.
<input type="text" name="quantity" value="1">
variations
If variations have been configured for the product, detected using the product.options variable, these will need to be selected and the selections submitted on the product form. This is a platform requirement, else the form will not submit.
{% for option in product.options %} {{ option.name }}<!-- e.g. 'size' --> <select name="value[]" class="product-option"> <option value="">Select...</option> {% for value in option.values %} <option value="{{ value.id }}">{{ value.name }}</option> {% endfor %} </select> {% endfor %}
choices
If product choices have been configured for the product, detected using the product.alt_options variable, the choices can be submitted with the product form.
{% for option in product.alt_options %} {{ option.name }}<!-- e.g. 'material' --> <select name="alt2_attribute_id[]" data-alternative="1"> <option value="">Select...</option> {% for value in option.values %} <option value="{{ value.id }}">{{ value.name }} +{{ currency_value(value.price) }}</option> {% endfor %} </select> {% endfor %}
extras
if product extras have been configured for the product, detected using the product.extras variable, whether any extra has been chosen by the customer can be submitted with the product form.
{% for extra in product.extras %} <input type="checkbox" name="product_extras[]" value="{{ extra.id }}"> {{ extra.name }} {{ currency_value(extra.price) }} {% endfor %}
customisation fields
If customisation fields have been configured for the product, detected using the product.customization_fields variable, the entries can be submitted with the product form.
{% for field in product.customization_fields %} {{ field.label }} {% if field.type == 1 %}<!-- a normal text input --> <input type="text" name="customization_field[{{ field.id }}]" maxlength="{{ field.max_length ? field.max_length : '65535' }}"> {% elseif field.type == 2 %} <textarea rows="5" cols="30" name="customization_field[{{ field.id }}]" maxlength="{{ field.max_length ? field.max_length : '65535' }}"></textarea> {% endif %} {% endfor %}
user files
If user files have been configured for the product, detected using
product.user_files > 0 variable, the uploads can be submitted with the product form.
The enctype="multipart/form-data" attribute should be set on the form.
{% if product.user_files > 0 %} {% for i in 1..product.user_files %} <input type="file" name="files[]"> {% endfor %} {% endif %}