Question

I have added a recently viewed widget in home page enter image description here

I want to remove add to cart button in the recently viewed widget.

Was it helpful?

Solution

Copy the below file to your theme:

vendor/magento/module-reports/view/frontend/templates/widget/viewed/content/viewed_grid.phtml

Your file location will be like below:

app/design/frontend/[Vendor]/[theme]]/Magento_Reports/templates/widget/viewed/content/viewed_grid.phtml

Below is the php code which you will find top of the above file:

<?php
if ($exist = ($block->getRecentlyViewedProducts() && $block->getRecentlyViewedProducts()->getSize())) {
    $type = 'widget-viewed';
    $mode = 'grid';

    $type = $type . '-' . $mode;

    $image = 'recently_viewed_products_grid_content_widget';
    $title = __('Recently Viewed');
    $items = $block->getRecentlyViewedProducts();

    $showWishlist = true;
    $showCompare = true;
    $showCart = true;
    $rating = 'short';
    $description = ($mode == 'list') ? true : false;
}
?>

You need to set $showCart = false to hide "Add to cart" button. And you can manage the contents according to your requirement.

Don't forget to flush the cache.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top