1

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.

  • How did you add the widget? – Anshu Mishra Jul 27 '18 at 12:22
  • with overidding template file you can change display. – P_U Jul 27 '18 at 12:23
  • @AnshuMishra widget added via admin side->addwidget – Nismath vi Jul 27 '18 at 12:24
  • @PareshaU vendor\magento\module-catalog\view\frontend\web\template\product\addtocart-button.html extended to ->app\design\frontend\Vendor\theme\Magento_Catalog\web\template\product\addtocart-button.html and vendor\magento\modulecatalog\view\base\web\template\product\list\listing.html extended to ->app\design\frontend\Vendor\theme\Magento_Catalog\web\template\product\list\listing.html – Nismath vi Jul 27 '18 at 12:26
  • @PareshaU I tried to remove add to cart button from above mentioned path but its not work – Nismath vi Jul 27 '18 at 12:27
2

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.

  • is there any additional folder that i need to copied to the theme? – Nismath vi Jul 27 '18 at 13:14
  • No need to copy anything. Only the above mentioned file. – Sukumar Gorai Jul 27 '18 at 13:14
  • button is still there – Nismath vi Jul 27 '18 at 13:16
  • Are you working with the correct template? – Sukumar Gorai Jul 27 '18 at 13:17
  • yeah i have working with Magento_catalog/templates/product/widget/viewed/grid.phtml – Nismath vi Jul 27 '18 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.