Conditional Custom Option
-
12-12-2019 - |
Question
I have a configurable product that has a few custom options.(i.e. custom text, font color) The product can be ordered with custom text on it and custom font color. What I am trying to achieve is, if the color of the product is black, I want to hide 'black' from the font color custom options drop down list.
Basically I need to set up some rules so that the customer does not order a dark colored product and also attempts to have a dark font color printed on it. What would be the best direction for me to take on achieving this?
Solution
- Get all the labels of color attribute for the product (as an array) [http://ka.lpe.sh/2012/09/13/magento-get-product-attribute-select-option-idlabelvalue/]
- Get all the custom option labels for the product (make sure this labels matches color attribute labels) (as an array) [https://stackoverflow.com/questions/2829164/how-to-get-custom-options-programmatically-in-magento]
- Write a jquery which triggers when color attribute value is changed, observe the current color label and hide same in custom option label. [https://stackoverflow.com/questions/6600281/jquery-if-select-option-equals-value-remove-value-on-second-select]
Make sense?
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange