I just installed magento-2 now. I want to remove 'add to cart' button. How can I do this?
If you are asking about "Hot seller" call out area then you can remove add to cart button using following way:
Magento created one Widget name with "Home page" and this widget has called into static block "home-page-block".
This widget has called
product/widget/content/grid.phtml
You can simple override your own created .phtml file with same without ""
Where is the
product/widget/content/grid.phtml
? I can't find it.
Home page means: the default index.php page with many product as grid view with "add to cart" button at bottom.
Hello @colam
it is inside \Magento\CatalogWidget\view\frontend\templates\product\widget\content
you need to check Magento\CatalogWidget module for same.
Hope it will help you.
I removed these lines under /var/www/html/magento/vendor/magento/module-catalog-widget/view/frontend/templates/product/widget/content>grid.phtml, still there is 'add to cart' button
<div class="actions-primary"> <?php if ($_item->isSaleable()): ?> <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?> <button class="action tocart primary" data-mage-init='{"redirectUrl":{"url":"<?= $block->escapeUrl($block->getAddToCartUrl($_item)) ?>"}}' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>"> <span><?= $block->escapeHtml(__('Add to Cart')) ?></span> </button> <?php else: ?> <?php $postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper'); $postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()]) ?> <button class="action tocart primary" data-post='<?= /* @noEscape */ $postData ?>' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>"> <span><?= $block->escapeHtml(__('Add to Cart')) ?></span> </button> <?php endif; ?> <?php else: ?> <?php if ($_item->getIsSalable()): ?> <div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div> <?php else: ?> <div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div> <?php endif; ?> <?php endif; ?> </div>
Hello @colam
please flush cache and check it.
If still not working then enable hint path and check which file calling.
but
you can not change into core files, either you need to take into your theme or into your module
How can I enable hint path?
"either you need to take into your theme or into your module" how can I do it?
Hi @colam
Re : How can I enable hint path?
Note : You will find developer menu only when you are in Default or Developer mode - if you are in production mode then this Developer menu is hidden - so you need to change your mode if its not showing Developer menu to you !!
RE : "either you need to take into your theme or into your module" how can I do it?
- Meaning editing directly core files its not a preferable way - so you either need to create a custom module or custom theme to override this addtocart.phtml file to hide the addtocart button.
Now below i am sharing two links which gives you idea that how to create a module and hide the add to cart button .
https://magenticians.com/magento-2-disable-add-to-cart-button/
https://magenticians.com/hide-add-to-cart-guest-users-magento-2/
Hope it helps you !!