I want to remove edit and delete button from mini-cart and cart page for specific product only. How can I do this? Any help would be appreciated. Thanks.

  • Can you please share on which criteria you want to hide edit/delete option for specific product? I mean conditions for specific product. Commented Jun 6, 2019 at 6:55
  • @DharaBhatti if i have multiple products in minicart/cart then i want to hide or remove edit/delete button for specific product only Commented Jun 6, 2019 at 7:07
  • You can use jquery like : if added 4 or more products then .minicart-items .product.actions{display:none;} Commented Jun 6, 2019 at 7:09
  • @DharaBhatti If "ABC" product in minicart/cart then i want to remove or hide edit/delete button from "ABC" product only. Commented Jun 6, 2019 at 7:20

1 Answer 1


To simply remove the edit/delete links in mini-cart you can extend the below file on your theme or in module and remove the product actions div class


But to remove based condition you have to create plugin for the class


The above file is method doGetItemData() passes the arguments for the buttons display

So our plugin di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <type name="Magento\Checkout\CustomerData\DefaultItem">
        <plugin name="Yourmodule_Checkout::add-custom-attribute-to-cart-minicart"
                type="Yourmodule\Checkout\Plugin\Checkout\CustomerData\DefaultItemPlugin" />

and the plugin file DefaultItemPlugin.php

    namespace Yourmodule\Checkout\Plugin\Checkout\CustomerData;
    class DefaultItemPlugin
         * @var \Magento\Catalog\Api\ProductRepositoryInterface
        private $productRepository;
        public function __construct(
            \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
        ) {
            $this->productRepository = $productRepository;
        public function afterGetItemData(\Magento\Checkout\CustomerData\DefaultItem $subject, $result)
            $product = $this->productRepository->get($result['product_sku']);
            return \array_merge(
                ['our_custom_attribute' => $this->showlinks()], 
       protected function canDisplayActionLinks()
             if (condition check) {
              return false;
           } else {
            return true;

Now in our default.html file under "product actions" div class check for our_custom_attribute value and display links accordingly

<div class="product actions">
                <!-- ko if: showlinks -->
                <!-- ko if: is_visible_in_site_visibility -->
                <div class="primary">
                    <a data-bind="attr: {href: configure_url, title: $t('Edit item')}" class="action edit">
                        <span data-bind="i18n: 'Edit'"></span>
                <!-- /ko -->
                <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'"></span>
                <!-- /ko -->

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.