I'm really struggling with the following scenario:

On the checkout page, you have an action toolbar for each product: - Add to wishlist - Edit - Remove

Now, I'm trying to hide the 'Edit' function from the frontend when the product that has been added to the cart is an simple product. The edit button has no function for these particular products, so I'd love to see it not being there.

I've been trying to modify the default.phtml, with the following code:

 <?php if (!$product->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE): ?>
                <script type="text/javascript">window.alert('test alert')</script>
                <style type="text/css">.action.action-edit{display:none;}</style>
 <?php endif;?>

It verifies if the product is not an configurable product, and if not (so it is an simple product), it hides the action-edit. But of course, this will remove it for every item in cart.

I could not figure out where else to put the code or how to do it differently. If someone is able to help, I'd be grateful.

2 Answers 2


You don't have to edit any template, you can simply do it with xml.

Add Magento_Checkout/layout/checkout_cart_item_renderers.xml to your theme:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="checkout.cart.item.renderers.simple.actions.edit" remove="true"/>
        <referenceBlock name="checkout.cart.item.renderers.grouped.actions.edit" remove="true"/>

The xml above will remove the 'Edit' link block for simple and grouped products. This can be done for other product types as well (but for some you probably shouldn't):

<referenceBlock name="checkout.cart.item.renderers.downloadable.actions.edit" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.configurable.actions.edit" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.virtual.actions.edit" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.bundle.actions.edit" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.giftcard.actions.edit" remove="true"/>
  • what if i want to remove these block on some condition? how it will be done.
    – Ali Raza
    Dec 4, 2020 at 10:46

Okay, I finally figured it out. I found the .phtml responsible for rendering the edit button:


I copied the file to:


Inside this code I added the following variables:

$_item = $block->getItem();
$product = $_item->getProduct();

Next, I changed:

<?php if ($block->isProductVisibleInSiteVisibility()): ?>


<?php if ($product->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE): ?>

So the total looks like this:

 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

// @codingStandardsIgnoreFile

// needed variables for checking if product is configurable or not
$_item = $block->getItem();
$product = $_item->getProduct();
/** @var $block \Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit */
<?php if ($product->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE): ?>
    <a class="action action-edit"
       href="<?= /* @escapeNotVerified */ $block->getConfigureUrl() ?>"
       title="<?= $block->escapeHtml(__('Edit item parameters')) ?>">
            <?= /* @escapeNotVerified */ __('Edit') ?>
<?php endif ?>

And now the edit button only shows when the product in the cart page is a configurable product. Hope this will help others in the future too.

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.