Skip to content

Instantly share code, notes, and snippets.

@mbrochh
Created June 29, 2011 07:58
Show Gist options
  • Save mbrochh/1053371 to your computer and use it in GitHub Desktop.
Save mbrochh/1053371 to your computer and use it in GitHub Desktop.
Providing drop down lists for simplevariations
{% load simplevariation_tags %}
<!-- Your product detail view here -->
<form method="post" action="{% url cart %}">{% csrf_token %}
{% with option_groups=object|get_option_groups %}
{% if option_groups %}
<div>
<h2>Variations:</h2>
{% for option_group in option_groups %}
<label for="add_item_option_group_{{ option_group.id }}">{{ option_group.name }}</label>
{% with options=option_group|get_options %}
<select name="add_item_option_group_{{ option_group.id }}">
{% for option in options %}
<option value="{{ option.id }}">{{ option.name }}</option>
{% endfor %}
</select>
{% endwith %}
{% endfor %}
</div>
{% endif %}
{% endwith %}
<input type="hidden" name="add_item_id" value="{{object.id}}">
<input type="hidden" name="add_item_quantity" value="1">
<input type="submit" value="Add to cart">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment