Magento 2 cant override the minicart.html file using html
-
30-03-2021 - |
Pergunta
I am going to override the minicart.html file using knockout for my custom code as below at the default file location is :
/var/www/html/magento226/pub/static/frontend/Magento/luma/en_US/Magento_Checkout/template/minicart/item/default.html
code
<!-- ko if: customracking.length -->
<div class="product customracking" data-mage-init='{"collapsible":{"openedState": "active", "saveState": false}}'>
<span data-role="title" class="toggle"><!-- ko text: 'Custom Racking Details' --><!-- /ko --></span>
<div data-role="content" class="content">
<strong class="subtitle"><!-- ko text: 'Custom Racking Details' --><!-- /ko --></strong>
<dl class="product customracking list">
<!-- ko foreach: { data: customracking as: 'custom' } -->
<dt class="label"><!-- ko text: custom.label --><!-- /ko --></dt>
<dd class="values">
<!-- ko if: Array.isArray(custom.value) -->
<span data-bind="html: custom.value.join('<br>')"></span>
<!-- /ko -->
<!-- ko ifnot: Array.isArray(custom.value) -->
<span data-bind="html: custom.value"></span>
<!-- /ko -->
</dd>
<!-- /ko -->
</dl>
</div>
</div>
<!-- /ko -->
Can anybody let me know how to solve this?
If anyone know, please let me help me out.
Thanks!
Solução
override in theme file location :
app/design/frontend/Magento/luma/Magento_Checkout/web/template/minicart/item/default.html
After changes in default.html file, we have to deploy static file using command,
php bin/magento setup:static-content:deploy -f
php bin/magento cache:clean
php bin/magento cache:flush
Outras dicas
i got the solution for the error : customracking.lengh can not bind using knockout so i update the function in the file :
Magento\Checkout\CustomerData\DefaultItem.php
protected function getCustomRacking()
{
$data = array('0'=>array('label'=>'test','value'=>'123'),'1'=>array('label'=>'hello','value'=>'456'));
return $data;
}
but this array did not consume as a foreach in knockout now the magento will rendor the custom array in html file using knockout in minicart same as product option render.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange