I've used app/design/frontend/<your_vendor_name>/<your_theme_name>/Magento_Catalog/templates/product/list/items.phtml
to set $showCart = true;
so that an Add to Cart button is used for related products rather than checkboxes.
<?php
switch ($type = $block->getType()) {
case 'related-rule':
if ($exist = $block->hasItems()) {
$type = 'related';
$class = $type;
$image = 'related_products_list';
$title = __('Related Products');
$items = $block->getAllItems();
$limit = $block->getPositionLimit();
$shuffle = (int) $block->isShuffled();
$canItemsAddToCart = $block->canItemsAddToCart();
$showAddTo = true;
$showCart = true;
$templateType = null;
$description = false;
}
break;
Is there a way for me to remove the checkboxes for adding the related products to the cart?
I know I could use CSS to simply hide the checkboxes but am wondering if there is a better way?
Best Answer
I found these posts to be helpful in overriding the checkboxes on the Related Products and replacing with Add to Cart buttons:
In
vendor/magento/module-catalog/view/frontend/templates/product/list/items.phtml
Change
$showCart = true;
in the switch statement, case:related_rule
orrelated
.Some template customization may come after this to completely remove the checkboxes, and I suggest copying this vendor file into your theme