Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This may already be possible but if so I can't work it out.
On my product I have a length attribute with some pre defined values, but I also want the option for the customer to chose there own length, so there would be an option of per meter.
I have created a custom line item which includes a field in which they can enter there own length value but I only want to display this field if the per meter attribute is selected. Is this possible?
Comments
Comment #1
marcus178 CreditAttribution: marcus178 commentedOk found a way of doing it, think it could be better but it works.
Firstly I hide the customisable field and wrap it in a div.
Then detecting when the attribute is changed can be done through the following commerce hook
I would have hoped there was a better to target the element that needs to be shown and hidden but every time I change the attribute the id changes which is why I've wrapped it in a div.
Comment #2
nvahalik CreditAttribution: nvahalik at Centarro commentedUse the Select or Other module to accomplish this. Here is an example.