I'm using 6.x-1.x-dev and when I have an attribute that has two separate enable rules, said attribute doesn't show up in the cart. For example, if I have an attribute that allows me to select one or two players and then shows a corresponding number of text fields for player's names, I might have the rules:
(# of players)-> disable (P1 name), disable (P2 name)
(1 Player)-> enable (P1 name), disable (P2 name)
(2 Players)-> enable (P1 name), enable (P2 name)

However, when I add the item to my shopping cart, (# of players) show up, but (P1 name) never shows up. (P2 name) should if I select 2 players. Upon closer inspection, I found that (P1 name) was being unset due to the clause referred to in the comments as "Is the attribute match a miss and are we an enable?". Therefore:
Choose (1 Player), there is an enable rule for (2 Players) that is an enable and misses the attribute match = unset.
Choose (2 Players), there is an enable rule for (1 Player) that is an enable and misses the attribute match = unset.
In both cases there is an attribute that gets unset but that should be kept.

I worked around this by creating a "protected_attributes" array and added logic to ensure that properly enabled attributes were preserved throughout the uc_conditional_attributes_remove_hidden_attributes function. I've attached a patch containing the changes I made.

Comments

jordotech’s picture

thanks for the patch, I might be running into this problem soon. I've already had to apply multiple changes for this module to work on my site, will be adding patches too.

rgrms’s picture

I tried this patch, thank you, it works!
However, 1 more a bit urgent question/suggestion: after applying the patch, at product page everything is ok, but at cart and order pages all fields are being shown, even if they empty. How to unset that empty fields?

E.g. i'm selling events and have a dropdown-list "Participants" list with values 1...10 and 10 textfields ("Name of the participant #"), so when I select 2 in drop down, i have to get 2 textfields, if 5 - 5 and so on, but e.g. in case of 5 if i submit into cart, i get:

Participants: 5
Name of the participant #1: Alex
Name of the participant #2: George
Name of the participant #3: Max
Name of the participant #4: Austin
Name of the participant #5: John
Name of the participant #6:
Name of the participant #7:
Name of the participant #8:
Name of the participant #9:
Name of the participant #10:

How to fix?

stewart.adam’s picture

Issue tags: +6.x-1.x blocker

Sorry for the delayed response, I thought that this project was a member of my 'always notify' notification group but it must have slipped through the cracks.

I'll be looking into this shortly, this looks like another bug in the dependency parser logic.

rgrms’s picture

Thank you in advance, the help is still much appreciated.

stewart.adam’s picture

jdickmann, thank you for the patch and detailed description of the problem - this was very helpful in reproducing the issue.

I have been able to reliably reproduce the issue on a test site and I believe this is due the same type of logic error that I recently fixed in the JavaScript dependency resolver in #1613314: Nested dependent atttributes not hiding and unsetting once parent option changed. I have rewritten the PHP dependency resolver to match the same new logic of the JavaScript one and I think you'll find that it works as expected now. Please apply both this patch and the one from comment #6 of the other issue while testing.

Because this patch redoes the dependency resolver entirely, also please re-download the module / undo the patch from #1 before testing.

stewart.adam’s picture

Status: Active » Fixed

Committed to dev, release coming soon.

Automatically closed -- issue fixed for 2 weeks with no activity.