mc12345678 / Stock_By_Attributes_Combined

This combines the Files from SBA 1.5.3 and SBA 1.5.4 to provide a single distribution for updating applicable to ZC 1.5.0, 1.5.1, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7 and 1.5.8.
GNU General Public License v2.0
6 stars 8 forks source link

Multiple Dropdowns Repeats First Option #103

Open david-fairbanks42 opened 3 years ago

david-fairbanks42 commented 3 years ago

I'm trying to use the multiple dropdowns option with products that have two attributes for the user to select from. I'm getting the first attribute repeated twice. Looking through the code it looks like pad_multiple_dropdowns line 108 should be using $attributes[$o] not $attributes[0].

mc12345678 commented 3 years ago

As written in the original plugin of Dynamic Dropdowns: https://www.zen-cart.com/downloads.php?do=file&id=672, The "multiple dropdowns" was basically incorrectly named. Its design became that to be shown when a single option name existed with multiple option values. That is why implementation in this module uses it only for "single attributes" and uses the sba_sequenced dropdowns for product that have more than one option name.

One is welcome to modify that portion of the code; however, understand that as implemented in SBA, the customer is not given any help when the multiple dropdowns option is used as considered. For example: Product has attributes A and B. Attribute A has option values 1, 2, and 3. Attribute B has option values 4, 5, and 6. Stock is something like: Quantity of product identified in product information page: 100 Method 1: Each option value has its own quantity. A-1: 8 A-2: 9 A-3: 10 B-4: 11 B-5: 12 B-6: 0 OR: Method 2: combination of option values identifies a unique stock quantity. A-1,B-4: 14 A-1,B-5: 15 A-1,B-6: 0 A-2,B-4: 17 A-2,B-5: (not defined) A-2,B-6: 19 A-3,B-4: 0 A-3,B-5: 21 A-3,B-6: 22

So... if using the first method of setup where each item (option value) has its own quantity, what stock quantity and by what method will the available stock be displayed to the customer for purchase of the product? The maximum product that can be purchased during these selections is the minimum of whatever option value is currently selected. So, if the customer picked first B-5, would they be shown 12, select attribute A, unknown, 0 or some other value? Then once they select an A value such as A-2 would they then be shown the number 9? Or would they not be shown anything in any case? If nothing is shown and they happen to select B-6 whether first or last and are told that there are no product available, what option should they change? How do they know?

In the second method, where stock is provided in combinations of option values, nearly the same thing applies about choosing one before/after the other... If javascript/jQuery is used to "disable" either the A value or the B value when a paired quantity is 0, what is then used to "reset" the selections so that an alternate option is made available? What if the customer were to first pick A-1, would B-6 become disabled? Even though A-2, B-6 has stock? What about if one picks B-5 first, what value would be shown: 100 (available quantity of the base product which is selectable through A-2, B-5), 21, 15 or something else?

It is because of these additional concerns that no further development was made on pad_multiple_dropdowns because of the multiple variations that could be taken. That said, the code was cleaned up to support/help others like yourself to adapt the code, but such modification is made for/by those that believe they have a direct need for that method of selection instead of how it has been implemented.

This issue has also been brought up at least in the forum at post 3305 (found by searching on pad_multiple_dropdowns though I thought I remembered other discussions which may be/have been in PMs or other threads on the zen-cart.com site) with a similar but (nearly always) different explanation. Note further, that the overall system supports adding yet another pad_ style display without losing the existing functionality by adding the file to the directory structure and the option to the database selections (or forcing the value by sql) to support that other/alternate file where/when desired.

For example, in the readme.txt of 1.3.7 of the above plugin, there is/was this list of known issues:

=============
KNOWN ISSUES:
=============

1. The single_dropdown option does not work correctly as it does not add the item with the selected attribute. I hope to have this fixed soon. To get around this use multiple_dropdown or sequenced_dropdown options for the single attribute configuration. 

2. Multiple_drop down does not work with multiple attributes, a regular expression needs to be fixed. Use the sequenced_dropdown for more than one attribute.

3. This code is far from optimized and does not follow all the Zen Cart standards. I hope to have this cleaned up over time with the help of the community.

4. The single_radioset option is not tested.

While many of those things were "fixed" and/or tested, focus was kept on the aspects that provided what is/was perceived as the optimum end using customer's experience. Not saying that there isn't still an issue even with that in mind, but...

I look forwards to the day/time when I just implement an ajax style method using javascript/jQuery predesigned boxes that support manual entry/filtering to make a selection. Those types exist; however, the design has not been implemented here.

mc12345678 commented 3 years ago

A question though, what is/was the problem with using the sba sequential dropdown method for multiple attributes and or why pad_multiple_dropdowns was chosen to be used?

Perhaps there is reason to pick up additional development.

david-fairbanks42 commented 3 years ago

SBA sequenced dropdowns was showing all the options as out of stock. But the issue was a missing record in the products_with_stock_attributes_stock_attributes_non_stock. I'm sure it was missing because of the database state during the update. Since it is a production installation, I needed to fix it quickly so that's why I was looking at other dropdown plugins.

mc12345678 commented 3 years ago

Are you able to recall and/or identify the process that was used to cause this issue?

Anything that could help is likely to help prevent it from occurring again, even if there was a need to perform a check of database status on the SBA admin page. Also, what then was done to correct the missing entry? Thanks for supporting addressing what appears to have been an alternate issue than just the multiple dropdown code.

david-fairbanks42 commented 3 years ago

Despite having the installation under version control, the history is a little fuzzy but here's what I remember.

SBA was installed and operating for years. Based on my git history, it looks to be version 1.5.3. Upgraded to 1.5.4 for a short period of time then upgraded to the current 1.5.5. Each time using the "Full/Upgrade DB Install" option in the admin setup page.

At some point the table products_with_stock_attributes_stock_attributes_non_stock got added but it was empty. To fix the problem, I commented out the check for the tables existence and the create table command to execute just the insert statement using the "Non-Stock DB Table Install".