- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
Magento. How to hide prices and Add to cart button for non-logged in visitors
November 4, 2015
This tutorial will show you how to hide prices and Add to cart button for guest users in Magento.
Magento. How to hide prices and Add to cart button for non-logged in visitors
-
Connect to your server using FTP client or the File Manager from your Hosting Cpanel.
-
Open price.phtml file from app/design/frontend/tm_themes/themeXXX/template/catalog/product/ where XXX is the number of your theme, and then place the following code on top of it:
isLoggedIn()){ echo 'Login to See Price
'; return; } ?> -
Now we will hide the ‘Add to Cart’ button on category list page. Open /app/design/frontend/default/themeXXX/template/catalog/product/list.phtml file and look for the following code:
isSaleable()): ?>
__('Out of stock') ?>
and replace it with:
isLoggedIn()){ echo 'Login to Add to Cart'; } else{ ?> isSaleable()): ?>
__('Out of stock') ?>
Note: look for
andand perform the same changes:Save changes:
Now we will hide the ‘Add to Cart’ button on product detail page. Open app/design/frontend/default/themeXXX/template/catalog/product/view/addtocart.phtml file. Add the following code on top of it:
isLoggedIn()){ echo 'Login to Add to Cart'; return;< } ?>
Save changes.
In order to hide the ‘Add to Cart’ button on compare page, open /app/design/frontend/base/default/template/catalog/product/compare/list.phtml file and copy it to /app/design/frontend/default/themeXXX/template/catalog/product/compare/ folder. Open it and look for the following code:
isSaleable()): ?>
__('Out of stock') ?>
and replace it with:
isLoggedIn()){ echo 'Login to Add to Cart'; } else{ ?> isSaleable()): ?>
__('Out of stock') ?>
Save changes.
In order to hide the ‘Add to Cart’ button on Specials page, open /app/design/frontend/tm_themes/themeXXX/template/catalog/product/widget/sale/sale_default_list.phtml file and look for the following code:
isSaleable()): ?>
__('Out of stock') ?>
and replace it with:
isLoggedIn()){ echo 'Login to Add to Cart'; } else{ ?> isSaleable()): ?>
__('Out of stock') ?>
Save changes.
In order to hide the ‘Add to Cart’ button for new products, open /app/design/frontend/tm_themes/themeXXX/template/catalog/product/widget/new/content/new_grid.phtml file and look for the following code:
isSaleable()): ?>
__('Out of stock') ?>
and replace it with:
isLoggedIn()){ echo 'Login to Add to Cart'; } else{ ?> isSaleable()): ?>
__('Out of stock') ?>
Save changes.
If you need to find out the location of the file which is used for the page or block not mentioned in this tutorial, please use Magento debug tool (Template Path Hints) following this tutorial on using Magento debug tool (Template Path Hints).
Feel free to check the detailed video tutorial below:
Magento. How to hide prices and Add to cart button for non-logged in visitors