Post by ianhaney50 » Tue Jun 24, 2025 4:59 am

I added a textarea box in the option tab of the admin product form page next to the select dropdown option value column in opencart 3.0.4.0.

On the front end, the options are radio buttons so for example if I select a specific radio product option, it shows the text description related to the option selected just above the add to cart button

I currently got the following code but that just shows all the options for the product and I would like to click on option value 17 radio button and it shows the text description related to number 17 option then if I click on option value 18 and it shows the text description related to number 18 option

Code: Select all

<!-- FOR OPTION TEXT FOR RADIO OPTIONS VALUES -->
              {% if options %}
{% for option in options %}
{% if option.type == 'radio' %}
<div id="input-option{{ option.product_option_id }}">
    {% for option_value in option.product_option_value %}
    <span style="font-weight: bold;">{{ option_value.name }}</span>
    <br>
    {{ option_value.o_description }}
{% endfor %}
</div>
{% endif %}
{% endfor %}
{% endif %}
Last edited by ianhaney50 on Wed Jun 25, 2025 1:25 am, edited 2 times in total.

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am

Post by marilyn55david » Tue Jun 24, 2025 2:22 pm

To display the description dynamically when a radio button option is selected in OpenCart 3.0.4.0, you need to embed the option description within a data-description attribute on each radio input in your Twig template. Then, use jQuery to listen for change events on these radio buttons. When an option is selected, retrieve its data-description value and update a dedicated display div (which should initially be hidden) with this content, effectively showing only the description for the currently selected option.


Posts

Joined
Tue Jun 24, 2025 2:15 pm

Post by Cue4cheap » Tue Jun 24, 2025 9:44 pm

marilyn55david wrote:
Tue Jun 24, 2025 2:22 pm
To display the description dynamically ....
<SNIP>
Sounds like an AI reply, new "users" first post too.

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by ianhaney50 » Wed Jun 25, 2025 1:23 am

Cue4cheap wrote:
Tue Jun 24, 2025 9:44 pm
marilyn55david wrote:
Tue Jun 24, 2025 2:22 pm
To display the description dynamically ....
<SNIP>
Sounds like an AI reply, new "users" first post too.
I thought that and thought it was bit of a robotic reply and didn't seem to be written by a human.

I've managed to solve the issue I was having, if anyone needs the coding to how I did it, post a comment on this topic and I'll post the code and hop eit can help others

Active Member

Posts

Joined
Fri Apr 29, 2016 4:21 am
Who is online

Users browsing this forum: AdsBot [Google], Ask Jeeves [Bot], FAST WebCrawler [Crawler], Semrush [Bot], W3C [Validator] and 29 guests