Step 1) Create di.xml
1 2 3 4 5 6 7 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <type name="Magento\Checkout\Model\DefaultConfigProvider"> <plugin name="AddAttPlug" type="[vendor]\[module]\Model\Plugin\DefaultConfigProvider" /> </type> </config> |
Step 2) create plugin file DefaultConfigProvider.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
class DefaultConfigProvider { /** *@var checkoutSession */ protected $checkoutSession; /** *Constructor * @param CheckoutSession $checkoutSession */ public function __construct(CheckoutSession $checkoutSession) { $this->checkoutSession = $checkoutSession; } public function afterGetConfig(\Magento\Checkout\Model\DefaultConfigProvider $subject, $config) { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); foreach ($config['quoteItemData'] as &$item) { $priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data'); $quoteItem = $this->checkoutSession->getQuote()->getItemById($item['item_id']); $price = $quoteItem->getProduct()->getPrice(); $formattedPrice = $priceHelper->currency($price, true, false); $item['originalprice'] = $formattedPrice; } return $config; } } |
Step 3) Override the /vendor/magento/module-checkout/view/frontend/web/js/view/summary/item/details.js to your module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ define([ 'uiComponent', 'Magento_Checkout/js/model/quote' ], function (Component) { 'use strict'; return Component.extend({ defaults: { template: 'Magento_Checkout/summary/item/details' }, /** * @param {Object} quoteItem * @return {String} */ getValue: function (quoteItem) { return quoteItem.name; }, getItemBaseprice: function (quoteItem) { return this.getPropertyDataFromItem(quoteItem, 'originalprice'); }, getPropertyDataFromItem: function (quoteItem, propertyName) { var property, itemDetails; if (quoteItem.hasOwnProperty(propertyName)) { property = quoteItem[propertyName]; } var quoteItem = this.getItemFromQuote(quoteItem); if (quoteItem.hasOwnProperty(propertyName)) { property = quoteItem[propertyName]; } if (property) { this.storage().set('item_details' + quoteItem.item_id + propertyName, property); return property; } itemDetails = this.storage().get('item_details' + quoteItem.item_id + propertyName); return itemDetails ? itemDetails : false; }, getItemFromQuote: function (item) { var items = quote.getItems(); var quoteItems = items.filter(function (quoteItem) { return quoteItem.item_id == item.item_id; }); if (quoteItems.length == 0) { return false; } return quoteItems[0]; } }); }); |
Step 4) Override the vendor/magento/module-checkout/view/frontend/web/template/summary/item/details.html to your module add the below line.
1 |
<span class="originalprice" data-bind="text: getItemBaseprice($parent)"></span> |
[crayon-63d3d4f86f75c058699629/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.