cancel
Showing results for 
Search instead for 
Did you mean: 

How to display html content of custom option in magento 2.3

SOLVED
Highlighted

How to display html content of custom option in magento 2.3

Hello Everyone,

I'm stuck with with a problem please help.

I'm trying to add an html code on product custom option in admin with type selected as radio button. But when I save the product it simply takes the html code as string and displays the html content. 
Please check the screenshot: https://prnt.sc/ukl0km
Please help me!

Thanks in advance. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How to display html content of custom option in magento 2.3

Found a solution!

I've used php html_entity_decode() function to get the html content.
I've made changes in vendor/magento/module-catalog/view/base/templates/product/composite/fieldset/options/view/checkable.phtml file.

<span>
<?php
$str = $block->escapeHtml($value->getTitle());

?>
<?php echo html_entity_decode($str);?>
<!-- <?= $block->escapeHtml($value->getTitle()) ?> --> //comment this line
</span>
this solved my problem. Smiley Happy

View solution in original post

3 REPLIES 3
Highlighted

Re: How to display html content of custom option in magento 2.3

Hello @mamun_paul 

 

The product custom options are supposed to take only string values, you can't put anything in custom option, I guess you want to acknowledge customer about the colour details.

You can add HTML code as additional information in product description which you can find in same product edit section :

Catalog > Products > Choose Product > Edit > Content

 

Hope it helps !

 

Problem Solved ? Click on 'Kudos' & Accept as Solution to encourage to write more answers !
Highlighted

Re: How to display html content of custom option in magento 2.3

Thanks for your reply.
I wanted a custom option where on click of the option the user will redirect to the product.
I can give you an example which have the same functionality but its in M1
Please check this: https://www.froothie.com.au/optimum-9200a-2nd-gen
Please check the screenshot as well: https://prnt.sc/ukwe8a


Highlighted

Re: How to display html content of custom option in magento 2.3

Found a solution!

I've used php html_entity_decode() function to get the html content.
I've made changes in vendor/magento/module-catalog/view/base/templates/product/composite/fieldset/options/view/checkable.phtml file.

<span>
<?php
$str = $block->escapeHtml($value->getTitle());

?>
<?php echo html_entity_decode($str);?>
<!-- <?= $block->escapeHtml($value->getTitle()) ?> --> //comment this line
</span>
this solved my problem. Smiley Happy

View solution in original post