Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Don't set initial variant when none of variants has attributes
Marcin Gębala3ee472f48286
diff --git a/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js b/saleor/static/js/components/variantPicker/AttributeSelectionWidget.jsindex 1832ba07ef..f296142582 100644--- a/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js+++ b/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js@@ -6,7 +6,7 @@ export default class AttributeSelectionWidget extends Component {static propTypes = {attribute: PropTypes.object.isRequired,handleChange: PropTypes.func.isRequired,- selected: PropTypes.string.isRequired+ selected: PropTypes.string};handleChange = (event) => {diff --git a/saleor/static/js/components/variantPicker/VariantPicker.js b/saleor/static/js/components/variantPicker/VariantPicker.jsindex 3d510e9788..03ecb45f9c 100644--- a/saleor/static/js/components/variantPicker/VariantPicker.js+++ b/saleor/static/js/components/variantPicker/VariantPicker.js@@ -18,12 +18,14 @@ export default class VariantPicker extends Component {constructor(props) {super(props);const { variants } = this.props;- const matchedVariant = variants.length ? variants[0] : null;- const selection = matchedVariant ? matchedVariant.attributes : {};++ const variant = variants.filter(v => !!Object.keys(v.attributes).length)[0];+ const selection = variant ? variant.attributes : {};+this.state = {errors: {},quantity: 1,- variant: matchedVariant,+ variant: variant,selection: selection};}