I want to know if you can get the config value to html I have a class which provides the value for config Not sure how to get this checked in HTML
I have been looking at configproviderinterface
I want to know if you can get the config value to html I have a class which provides the value for config Not sure how to get this checked in HTML
I have been looking at configproviderinterface
Override DefaultItem customer data Magento\Checkout\CustomerData\DefaultItem
And you can call the additional to KOJS This should allow you to grab the config value
protected function doGetItemData() {
//add new here
e.g.
'check_enabled' => $this->Helper->getNewPrice(),
}
In you html
< !-- ko if: check_enabled ==1 -->
//do h tag which does test
< !-- ko -->
< !-- ko ifnot: check_enabled ==1 -->
do h tag which does testfailed
<!-- ko -->
I'll give an example for checkout page, the idea is to load your config module in phtml
, then you call that phtml
in html
We create our phtml:
app/design/frontend/{Vendor}/{theme}/Magento_Checkout/templates/html/my-custom.phtml
//you get your config module here then save it in $config
<?php echo $config; ?>
We instantiate our custom phtml:
app/design/frontend/{Vendor}/{theme}/Magento_Checkout/templates/onepage.phtml
/* The Magento onepage code first,
then we add our myphtml var bellow the initial file code,
this file if you haven't it yet in your current theme,
you can copy it from :
vendor\magento\module-checkout\view\frontend\templates\onepage.phtml*/
...
<?php $myphtml = $block->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magento_Theme::html/my-custom.phtml")->toHtml(); ?>
<script type="text/javascript">
var my_phtml = <?php echo json_encode($myphtml); ?>;
</script>
We go to our html then bind our phtml content
for exmple: we get our phtml in shipping.html
file:
app/design/frontend/{Vendor}/{theme}/Magento_Checkout/web/template/shipping.html
...
<div id="my-id" title="Information" data-bind="html:my_phtml"/> // here you get your config module value
I not tested it but it should work !