0

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!

2
  • 1
    you need to minicart file override in your custom theme Commented Jan 21, 2020 at 7:10
  • minicart.phtml? you want to say ? but minicart is rendering using the knockout i want to overrirte the knockout rendering template file.then how can i achieve this ? Commented Jan 21, 2020 at 7:16

2 Answers 2

2

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
7
  • i already overrite thay file but it will not reflacted even this <strong class="subtitle"><!-- ko text: 'Custom Racking Details' --><!-- /ko --></strong> ko text also not rendering i also cache clean setup upgrade and the deploy command run Commented Jan 21, 2020 at 7:18
  • @kinjalmehta Please verify file path Magento_Checkout/web/template/ or Magento_Checkout/template/ ? Commented Jan 21, 2020 at 7:20
  • it's a Magento_Checkout/web/template/ Commented Jan 21, 2020 at 7:28
  • @kinjalmehta You have to delete default.html file from => pub/static/frontend/Magento/luma/en_US/Magento_Checkout/template/minicart/item and reload page again. Commented Jan 21, 2020 at 8:42
  • i do done that command but i face the error like : Bindings value: foreach: { data: customracking as: 'custom' } Commented Jan 21, 2020 at 8:48
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.