In 11.0.3 the Real Time Stock system is erroneously setting Optional Component checkboxes to checked if the Component uses an Associated Product.
To see bug:
Use standard V11.0.3 site.
Select Digital Camera.
Add a Component. Check "Is Optional".
Apply changes and the Component checkbox should appear unchecked.
Now in Component Details / Associated Product, select Photo Frame.
Apply changes and the Component checkbox now becomes erroneously checked.
Cause:
No "checked" attribute is being put into the generated HTML. It's the Real Time Stock JavaScript that setting these checkboxes.
Problem seems to be the line highlighted in red in actinicextras.js in function updateStockDisplay.
Comment out that line and the checkbox being set stops happening.
Commenting out that line isn't the fix. I've a feeling that the line in question is intended for Radio Buttons and is intended to make at least one selected in case the first (usually checked) radio button has been removed by the RTS code.
So perhaps changing the line marked in green:
To:
May be a fix. I'm not fully sure what other job this code does so this may have side-effects.
To see bug:
Use standard V11.0.3 site.
Select Digital Camera.
Add a Component. Check "Is Optional".
Apply changes and the Component checkbox should appear unchecked.
Now in Component Details / Associated Product, select Photo Frame.
Apply changes and the Component checkbox now becomes erroneously checked.
Cause:
No "checked" attribute is being put into the generated HTML. It's the Real Time Stock JavaScript that setting these checkboxes.
Problem seems to be the line highlighted in red in actinicextras.js in function updateStockDisplay.
Code:
// // Check class name for associated prod refs // var oMatch = elemInput.className.match(reRTS); if (oMatch) { var sName = elemInput.name; // get cgi name of element if (!mapRBGroups[sName]) // if this is first time we've hit this name { // // Try and get the optional element // var elemOptional = elemInput.type == 'checkbox' ? elemInput : null; // if this is a checkbox, this is the optional element oMatch = elemInput.className.match(reChk); if (oMatch) // if optional element is in the class name elemOptional = document.getElementsByName(oMatch[1])[0]; // save it if (!elemOptional && mapOptComp[sName]) // is it in our map? elemOptional = mapOptComp[sName]; // save it var nInStockChoices = 0; // // Go though all elements with this name // var collNames = document.getElementsByName(sName); for (var n = 0; n < collNames.length; n++) { var elemName = collNames[n]; if (elemName.value == -1) elemOptional = elemName; // optional element is a radio button oMatch = elemName.className.match(reRTS); if (oMatch) // if this has an associated product { var sRef = oMatch[1]; // save product ref if (mapStockByRef[sRef] != undefined && // if we have a stock level mapStockByRef[sRef] <= 0) // and it's out of stock { elemName.disabled = true; // disable choice if (elemName.type == 'submit') { elemName.parentNode.style.display = 'none'; } } else // in stock or no stock level? { elemName.disabled = false; nInStockChoices++; // increment in-stock choices if (nInStockChoices == 1) // first choice? { elemName.checked = true; // select it } } } else if (elemName.type == 'submit' || // if this is a push-button elemName.value > 0) // or a real choice { elemName.disabled = false; nInStockChoices++; // increment in-stock choices if (nInStockChoices == 1) // first choice? { elemName.checked = true; // select it } } }
Commenting out that line isn't the fix. I've a feeling that the line in question is intended for Radio Buttons and is intended to make at least one selected in case the first (usually checked) radio button has been removed by the RTS code.
So perhaps changing the line marked in green:
Code:
if (nInStockChoices == 1)
Code:
if (nInStockChoices == 1 && elemName.type != 'checkbox')