First of all please override sidebar.js file in your custom theme.
So In theme, add a js file sidebar.js
to app\design\frontend\[NAMESPACE]\[THEME]\Magento_Checkout\web\js\sidebar.js
if not exist then copy form vendor\magento\module-checkout\view\frontend\web\js\sidebar.js
Now go to button.remove
function in sidebar.js
on line number 89 approx
, and replace the whole function with the following code.
/**
* @param {jQuery.Event} event
*/
events['click ' + this.options.button.remove] = function (event) {
event.stopPropagation();
/* Start code ok/cancel code */
var ok = document.createElement("button");
ok.innerHTML = "ok";
var confirmtext = document.createElement("div");
confirmtext.innerHTML = $.mage.__('Are you sure you would like to remove this item from the shopping cart?')
var cancel = document.createElement("button");
cancel.innerHTML = "cancel";
confirmtext.classList.add("rmprod");
ok.classList.add("rmprod");
cancel.classList.add("rmprod");
var prnt = $(event.target).parents('.product-item-details');
if(!prnt.has('.rmprod').length){
prnt.append(confirmtext);
prnt.append(ok);
prnt.append(cancel);
}
ok.addEventListener ("click", function() {
self._removeItem($(event.currentTarget));
});
cancel.addEventListener ("click", function() {
$(self.options.targetElement).dropdownDialog('close');
prnt.children('.rmprod').remove();
});
// confirm({
// content: self.options.confirmMessage,
// actions: {
// /** @inheritdoc */
// confirm: function () {
// self._removeItem($(event.currentTarget));
// },
// /** @inheritdoc */
// always: function (e) {
// e.stopImmediatePropagation();
// }
// }
// });
};
You can manage remove button from following file in your custom theme.
/app/design/frontend/[NAMESPACE]/[THEME]/Magento_Checkout/web/template/minicart/item/default.html
find the following in your default.html
file.
You can change the text following code and remove the button style using CSS.
<div class="secondary">
<a href="#" data-bind="attr: {'data-cart-item': item_id, title: $t('Remove item')}" class="action delete">
<span data-bind="i18n: 'Remove Item'"></span>
</a>
</div>
Cancel
andOk
button?