Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Module help to hide add button
 
thomas-mason
Jr. Member
 
Total Posts:  3
Joined:  2010-04-27
 

I have read many post on this site describing how to hide the add button on the list.phtml page… and I have done so by adding the following code to that file.

<?php if($this->helper('customer')->isLoggedIn()):?>
<button type="button" class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart'?></span></button>
 
<?php else: ?>
     
<button type="button" class="form-button" onclick="location.href='http://website.com/customer/account/create/'"><span><?php echo $this->__('Login to add to cart'?></span></button
 
<?php endif; ?>
I used that to replace
<button type="button" class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart'?></span></button>
Basically what this has done is if a user is not logged in, instead of the add button they will get a button that links them to the login page, if they are logged in they will get the standard add button. So here is my question right now this code is in a test environment, and it has edited the core files ( at least i think it has .. I am really new to this). So how could i go about making this into a module so that it can be used and still allow for upgrade later. I have seen many post related to how to make a module but they are all the standard “Hello World” , and I have yet to find anything that tells me how to implement something like this. Any help would be appreciated.
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top