Template – Change ‘Add to Cart’ Button to ‘View More’ on Category Page

product-listtemplate

I have looked at some other posts but need specific help with replacing the 'Add to cart' buttons on the category pages to 'view more' (linked to the product).

Here is the Grid view code from list.phtml

                 <?php if($_product->isSaleable()): ?>

                   <button type="button" onclick="setLocation('<?php echo $_product->getProductUrl() ?>')"><?php echo $this->__('View Details')?></button>

                    <?php if ( !($_product->getTypeInstance(true)->hasRequiredOptions($_product) || $_product->isGrouped()) ) { ?>
                    <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocationAjax('<?php echo $this->getAddToCartUrl($_product) ?>','<?php echo $_product->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                    <span class="cat_loader" id='ajax_loader<?php echo $_product->getId()?>' style='display:none'>
                    <span class="cart_msg">
                    <img alt="" src='<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>'/>
                   </span>
                   </span>

                    <?php } else { ?>


                        <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="showOptions('<?php echo $_product->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>

                    <?php }  ?>
                <?php else: ?>
                    <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                <?php endif; ?>

I have tried replacing the add-to-cart code with the following:

<button type="button" onclick="setLocation('<?php echo $_product->getProductUrl() ?>')"><?php echo $this->__('View Details')?></button>

Although, the Add to Cart button stays in place and I get an additional (badly formatted) one for the 'view details'.

Any suggestions to where I am going wrong please?

Best Answer

Best way is to edit translations instead of editing core template files which may get overwritten by updates. You can find concerned file in app > locale > en_US (or other localisation folder if using non US lang) > Mage_Catalog.csv. Look for Add to Cart text and replace with "Add to Cart","View More"

This however changes the button label on product page too so you can change the inline translation list.phtml file but make sure you do it in custom theme instead of editing it in default theme files which may get overwritten. Make changes everywhere where it says Add to Cart, replace it with view more, save the file and clear cache.