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.
Best Answer
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:
Next, I changed:
To
So the total looks like this:
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.