The default Magento 2 does not provide Edit and Remove product button in Order summary on the checkout page. But, it provides on Cart page and Mini-cart.
Follow the below instructions to set Edit and Remove product button Order summary on the checkout page.
Override details.html file in your theme
/app/design/frontend/[VendorName]/[theme]/Magento_Checkout/web/template/summary/item/details.html
And add below code in this file
1 2 3 4 5 6 7 8 9 10 |
<div class="primary"> <a data-bind="attr: {href: getConfigUrl($parent.item_id),title: $t('Edit item')}" class="action edit"> <span data-bind="i18n: 'Edit'"></span> </a> </div> <div class="secondary"> <a href="#" data-bind="attr: {'data-post': getDataPost($parent.item_id),title: $t('Delete item')}" class="action delete"> <span data-bind="i18n: 'Remove'"></span> </a> </div> |
Override details.js file in your theme
/app/design/frontend/[VendorName]/[theme]/Magento_Checkout/web/js/view/summary/item/details.js
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 56 57 58 59 60 61 62 63 64 65 66 |
define( [ 'uiComponent', 'mage/url', 'Magento_Customer/js/customer-data', 'jquery', 'ko', 'underscore', 'sidebar', 'mage/translate' ], function (Component,url,customerData,$,ko, _) { "use strict"; return Component.extend({ defaults: { template: 'Magento_Checkout/summary/item/details' }, getValue: function(quoteItem) { var itemId = elem.data('cart-item'), itemQty = elem.data('item-qty'); return quoteItem.name; }, getDataPost: function(itemId) { console.log(itemId); var itemsData = window.checkoutConfig.quoteItemData; var obj = {}; var obj = { data: {} }; itemsData.forEach(function (item) { if(item.item_id == itemId) { var mainlinkUrl = url.build('checkout/cart/delete/'); //var baseUrl = url.build('checkout/cart/'); var baseUrl = url.build('checkout/'); console.log(mainlinkUrl); obj.action = mainlinkUrl; obj.data.id= item.item_id; obj.data.uenc = btoa(baseUrl); } }); return JSON.stringify(obj); }, getConfigUrl: function(itemId) { var itemsData = window.checkoutConfig.quoteItemData; var configUrl = null; var mainlinkUrl = url.build('checkout/cart/configure'); var linkUrl; itemsData.forEach(function (item) { var itm_id = item.item_id; var product_id = item.product.entity_id; if(item.item_id == itemId) { linkUrl = mainlinkUrl+"/id/"+itm_id+"/product_id/"+product_id; } }); if(linkUrl != null) { return linkUrl; } else { return ''; } } }); } ); |
Then run below commands.
1 2 3 |
php bin/magento setup:upgrade php bin/magento setup:static-content:deploy php bin/magento cache:flush |
That’s all folks. Hope it worked for you.
[crayon-63d68650cfe04124763972/] 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.