I need to get a list under each product in the form: - Unit price - Amount - Amount based on price and quantity

Rewrite template: vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html

my Template

<div class="product-item-details">
    <div class="product-item-inner">
        <div class="product-item-name-block">
            <strong class="product-item-name" data-bind="html: $parent.name"></strong>
            <div class="price">
                <span class="label"><!-- ko i18n: 'Price' --><!-- /ko --></span>
                <span class="value" data-bind="text: $parent.price"></span>
            <div class="details-qty">
                <span class="label"><!-- ko i18n: 'Qty' --><!-- /ko --></span>
                <span class="value" data-bind="text: $parent.qty"></span>
            <!-- ko foreach: getRegion('after_details') -->
                <!-- ko template: getTemplate() --><!-- /ko -->
            <!-- /ko -->

code block

<div class="price">
    <span class="label"><!-- ko i18n: 'Price' --><!-- /ko --></span>
    <span class="value" data-bind="text: $parent.price"></span>

Must give a formatted price: 1.780,00 €

But on the front end, I see: 1780

I used the method: getFormattedPrice($parent.price)

but i was getting undefined

enter image description here


If you didn't also overwrite the js file for your template, the method getFormattedPrice is not defined in your component. That is why you get undefined when trying to use getFormattedPrice.

If you didn't overwrite it then the component for your tempalte is this one: vendor/magento/module-checkout/view/frontend/web/js/view/summary/item/details.js .

The file src/vendor/magento/module-checkout/view/frontend/web/js/view/summary/abstract-total.js defines the getFormattedPrice method you want to use.

I see 2 easy ways to fix this, so you can use getFormattedPrice in your template:

A) Extend details.js and implement getFormattedPrice the same way like abstract-total.js

B) Overwrite details.js and extend from abstract-total.js so you can use getFormattedPrice in your template

  • I rewrite in app/design/frontend/Custom/Theme/Magento_Checkout/web/js/view/summary/item/details.js and add getFormattedPrice: function (price) { return priceUtils.formatPrice(price, quote.getPriceFormat()); } + and added define 'Magento_Checkout/js/model/quote', 'Magento_Catalog/js/price-utils', but it didn’t work, please help – ann karsksya May 26 '20 at 15:54
  • still the same that you get undefined as result ? did you check if it uses the new version of your file ? (for example by having a look in the sources using the browser console) – Ekk4rd May 26 '20 at 16:22
  • oh, understand, I did not delete the cache, now everything is fine, thanks – ann karsksya May 26 '20 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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