Four51 / CustomSolutions

Custom Solutions
7 stars 15 forks source link

ProductMatrix - Default value of Variable Spec causes wrong Variant to be added to the cart #56

Open digitalalphas opened 6 years ago

digitalalphas commented 6 years ago

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.

matrix-1-varspec-default matrix-2-variants matrix-3-productpage matrix-4-cart-wrong-variant

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; }

mmoebeck commented 6 years ago

Thank you for the clear definition. We will review and update.