When a variable selection spec is configured to have a default value, that value is always used to construct the variant for the cart, meaning the wrong variant is added to the cart.
Unchecking the "default" option on the admin site is the quickest solution, but I think the code should also handle this scenario. I updated the _addToOrder function in the ProductMatrix factory of a client's version of productMatrix.js so they wouldn't have to update all of their products.
I updated the following lines from:
if(!liSpecs[spec].Value){ liSpecs[spec].Value = item.tempSpecs[spec] ? item.tempSpecs[spec].Value : null; }
To:
if(!liSpecs[spec].Value || (item.tempSpecs[spec] && liSpecs[spec].Value != item.tempSpecs[spec].Value)){ liSpecs[spec].Value = item.tempSpecs[spec] ? item.tempSpecs[spec].Value : null; }
When a variable selection spec is configured to have a default value, that value is always used to construct the variant for the cart, meaning the wrong variant is added to the cart.
Unchecking the "default" option on the admin site is the quickest solution, but I think the code should also handle this scenario. I updated the _addToOrder function in the ProductMatrix factory of a client's version of productMatrix.js so they wouldn't have to update all of their products.
I updated the following lines from:
if(!liSpecs[spec].Value){ liSpecs[spec].Value = item.tempSpecs[spec] ? item.tempSpecs[spec].Value : null; }
To:if(!liSpecs[spec].Value || (item.tempSpecs[spec] && liSpecs[spec].Value != item.tempSpecs[spec].Value)){ liSpecs[spec].Value = item.tempSpecs[spec] ? item.tempSpecs[spec].Value : null; }