potteryhouse / stock_by_attribute_1.5.4

Stock by Attribute for Zen Cart 1.5.3
GNU General Public License v2.0
2 stars 5 forks source link

incorrect display order of DD attributes #42

Closed mc12345678 closed 8 years ago

mc12345678 commented 8 years ago

Identified by @mattys in the ZC forum at one of the many SBA threads: The display of option values is not in the order generated by the Dynamic Dropdown code which is based on the sort order set in the attributes controller.

Direct Cause: "Key" (option_value_id) of the object is numeric and most browsers will "sort" the object based on that number. Related Cause: the sequence of the attributes is not held constant by the code, but instead incorrectly treated as if will be correctly sequenced by the "recipient" of the data.

Potential Temporary fix: Change the key to a string without effecting the add-to-cart process by attaching a single character (minimize additional data to be sent) to the key so that it will consistently be treated as a string. (This is not fully tested, but may at least work properly on 50% of the browsers.) Long term fix (correct fix and not a "patch". Recommend opening a new item after temporary fix is complete or invalidated): implement a coded method that will maintain the "sort" order. Two methods come to mind, 1) a simple array that is itself in a sequence associating the position in the array as the order and the value at that position as the option_value_id associated or 2) a javascript storage/operations structure that will maintain the data and the order. Both of these are well documented in stackoverflow.

mc12345678 commented 8 years ago

Temporary fix has been applied for the dynamic dropdowns sba variant added to Dynamic Dropdowns. See: dab36bce81c3fc78c2c3feb2f34fbcea721b3b4a A more permanent/controlled solution is still to be applied that manages the javascript side better (strictly controls the sequence) than currently provided.

Closing this item with item #44 to take its place to specifically address the long term solution.