Question

How to display add to block on related products similar to it is displaying on list page?

Was it helpful?

Solution

I am assuming you want to show add to cart, add to wish-list just like as on list page for related product on product view page.

As you know for showing related, upsell product there is a common file located at

vendor\magento\module-catalog\view\frontend\templates\product\list\items.phtml 

Copy above file to your theme, if not exist.

You can see in this phtml there is switch case for related and upsell product with some option.

There is already Add to cart button is available in this phtml, but with following condition:

if ($showAddTo || $showCart):

That means you need to set true to both above variables. Search $showAddTo and $showCart for related case and you will need to change

$showCart = true;

from

$showCart = false;

Above code will enable add to cart.

Note: If you need to hide add to cart checkbox and its label, it can be easily hide using CSS

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