Well I just found the first "semi-major" problem with the "magic" version.
Because of the way the magic works, it basically creates 2 copies of each module and uses javascript to figure out if it exists on the tabs, then hide the real one on the product display template. But it's only hiding it from your browser, the code still loads in the background.
Then i use jscript to set the real divs to be hidden, and change the rendered id of the tabbed version of the modules to have the real id name so that it uses the correct css settings. So its really an optical illusion. The actual source code will show 2 copies, while the rendered page will only show one.
The problem is that this is a form. So while the add to cart button does the send action, i forgot that there are other modifiers.... the attributes and the add to cart qty box.
It works fine for radio buttons. But for textboxes and dropdown boxes, there is a default value already set. So while changing it on the tab, the real version, which loads after the tabbed version, is hidden but still applies its own default value. Which means that the tabbed version gets over written when clicking add to cart. Same with the qty box. If you use the qty box option and enter qty 10.. it will use the default min qty number from the hidden one.
So to fix this I have 2 options.
Option 1.
I can:
- use php to save the actual name value of the tabbed version to a variable.
- Rename the name value to add "_tab" to the name so that when the real one loads they are uniquely named.
- Pass that php variable from step 1 to a jscript variable and match that name to the real one. Then change the real one on the rendered client to be something else.
- Then change the tabbed one to the real one to apply the form action when submitting.
The problem with this one is that I have not yet proven that the form will accept the jscript manipulated name vs the one that is in the code. If it doesn't, then this option is completely out of the water.
Option 2:
I can hybrid with the non-magic one for the add to cart and attributes in the product template. So instead of just 3 lines added to the template, you need to add 2 more IF statements. It would still be less changes than the old versions have needed to date.
Bookmarks