Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add GenericProductForm
Marcin Gębalaba2f09200a00
diff --git a/saleor/product/forms.py b/saleor/product/forms.pyindex 848bd5c7bd..5ddf1a6a68 100644--- a/saleor/product/forms.py+++ b/saleor/product/forms.py@@ -6,7 +6,17 @@ from ..product.models import GenericProductclass GenericProductForm(AddToCartForm):- pass+ name = forms.ChoiceField()++ def __init__(self, *args, **kwargs):+ super(GenericProductForm, self).__init__(*args, **kwargs)+ available_variants = [+ (v.sku, v.name) for v in self.product.variants.all()]+ self.fields['name'].choices = available_variants++ def get_variant(self, cleaned_data):+ name = cleaned_data['name']+ self.product.variants.get(name=name)class ProductVariantInline(forms.models.BaseInlineFormSet):