bobbingwide / vgc

VGC - Garden Vista Group theme
GNU General Public License v2.0
0 stars 0 forks source link

Optional Upgrades - Allow only ONE choice option only works when Required Addon also checked #41

Open bobbingwide opened 2 years ago

bobbingwide commented 2 years ago

While testing the logic for Installation options, where the price needed be displayed when it's PRICE ON ENQUIRY, I noted that the Allow only ONE choice option only works when the Required Addon checkbox was also ticked.

This doesn't seem to be logical.

image

I'd have expected...

Required Addon Processing
checked First option initially selected.
unchecked No option selected
Allow only ONE choice Processing
checked When an option is selected the previously chosen value is deselected
unchecked More than one option can be selected

I created examples of each combination for https://gvg.co.uk/store/deponti-bosco-veranda-4060x3000mm/#options_area

bobbingwide commented 2 years ago

There are two similar files that attempt to implement the logic in JavaScript.

addon-scripts.js is the file in current use _addon-scripts.js is the alternative

Their logic is different in a number of places. In addAddonToCart(), _addon-scripts.js calls dealWithRequiredAddons() when either the addon-select-required class is set ( Required addon is checked ) OR the addon-select-radio is class is set ( Allow only ONE choice is checked ).

The active file uses an AND ( && ) expression.

With the AND ( && ) expression it's not possible to Allow only ONE choice unless the Required Addon is checked.

With the OR ( || ) expression it's not possible to select more than one option when Required Addon is checked.

It would appear that a change was made prior to my starting work on this project, but since I don't know the requirements, I can't just switch the expression back from AND to OR until I know what was actually wanted.