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.
Solved! Go to Solution.
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.
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 !
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
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.
Thank you! working for me
Instead of making the changes in the core file, please override the html in your custom module and do the changes.