0

I try to display a custom product attribute instead of the price in minicart.

I saw that the html file that I have to override is price.html from module_checkout. price.html :

<!-- ko ifnot: true -->
     <div class="price-container">
         <span class="price-wrapper" data-bind="html: price"></span>
     </div>
<!-- /ko --> 
<!-- ko if: true -->
     custom attribute product value here
<!-- /ko -->

And I already override this html in a requirejs-config.js :

var config = {
//override price.html file
  map: {
    '*' : {
      'Magento_Checkout/template/minicart/item/price.html' : 'Vendor_Module/template/minicart/item/price.html'
    }
  }
};

I tried to put in that file a knockoutjs code if and ifnot, but I don't know how to retrieve my own product value in this html file. If someone know ?

Thanks in advance !

1 Answer 1

0

Hope you doing well.

Please clean/flush cache and deploy magento.

php bin/magento setup:static-content:deploy (add " -f " if it's in Developer mode

if condition not needed.

<!-- ko if: true -->

<!-- /ko -->

price.html is called from here.

/magento_directory/vendor/magento/module-checkout/view/frontend/web/template/minicart/item/default.html

<!-- ko foreach: $parent.getRegion('priceSidebar') -->
     <!-- ko template: {name: getTemplate(), data: item.product_price, as: 'price'} -->
     <!-- /ko -->
<!-- /ko -->

Price renderer is added using xml.

checkout_cart_sidebar_item_price_renderers.xml

so please first clear cache & Deploy.

Thanks

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.