How to hide your Add-to-Cart Button and your Product Price in OpenCart 2.0.x

As an OpenCart store owner you are well aware of the Add-to-Cart button and the product price that are displayed next to each product in your store. There are a few good reasons why you might want to remove these two, but unfortunately OpenCart doesn’t give you the possibility to disable them from the admin panel. This is why we have prepared this short tutorial for you that will show you how you can do this on your own. We will create two OCmod files that will make the needed modifications without the need of changing the core files.

So, keep on reading to learn how to:

1. Remove your Add-to-Cart button from your product, category and search pages as well as from the header of your web-store.

2. Remove the Product Prices from your product, category and search pages.

*Note that the tutorial is for the Default OpenCart 2.0.x theme, so if you are using a custom theme the modifications might not be applied.

Remove your Add-to-Cart button

In order to transform your website from a store to a catalog and remove the Add-to-Cart button as well as the Shopping Cart link from the header, you will need to follow these steps:

1.Create a new OCmod file by opening your preferred text-editor and save the file as nameofyoupreference.ocmod.xml.​ 

2.Copy and paste the following code, which is in fact the opening and the closing of the document:

<modification>
    <name>Hide Add to Cart Button</name>
    <version>1.0</version>
    <link>https://isenselabs.com</link>
    <author>iSenseLabs</author>
    <code>isenselabs_hide_add_to_cart</code>
    
    {body} 
   
</modification>

3. On the place of {body} copy and paste the following code snippets in order to:

Remove the Add-to-Cart button from the product page

<file path="catalog/view/theme/*/template/product/product.tpl">
<operation>
   <search><![CDATA[<button type="button" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>]]></search>
   <add position="replace"><![CDATA[
       <button type="button" style="display:none;" id="button-cart" data-loading-text="<?php echo $text_loading; ?>" class="btn btn-primary btn-lg btn-block"><?php echo $button_cart; ?></button>
    ]]></add>
</operation>
<operation>
    <search><![CDATA[<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>');"><span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span> <i class="fa fa-shopping-cart"></i></button>]]></search>
    <add position="replace"><![CDATA[
        <button type="button" style="display:none;" onclick="cart.add('<?php echo $product['product_id']; ?>');"><span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span> <i class="fa fa-shopping-cart"></i></button>
    ]]></add>
</operation>    
<operation>
    <search><![CDATA[<button type="button" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>]]></search>
    <add position="replace"><![CDATA[
         <button type="button" style="width:50%;" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>
    ]]></add>
</operation>
<operation>
    <search><![CDATA[<button type="button" data-toggle="tooltip" title="<?php echo $button_compare; ?>" onclick="compare.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>]]></search>
    <add position="replace"><![CDATA[
        <button type="button" style="width:50%;" data-toggle="tooltip" title="<?php echo $button_compare; ?>" onclick="compare.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>
    ]]></add>
</operation>          
</file>

 

rem_add_to_cart_product.PNG

 

remo_add_to_cart_prod_2.PNG

 

Remove the Add-To-Cart button from the category page:

<file path="catalog/view/theme/*/template/product/category.tpl">
<operation>
    <search><![CDATA[<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>]]></search>
    <add position="replace"><![CDATA[
       <button type="button" style="display:none;" onclick="cart.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>
    ]]></add>
</operation>    
<operation>
    <search><![CDATA[<button type="button" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>]]></search>
    <add position="replace"><![CDATA[
        <button type="button" style="width:50%;" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>
    ]]></add>
</operation>
<operation>
    <search><![CDATA[<button type="button" data-toggle="tooltip" title="<?php echo $button_compare; ?>" onclick="compare.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>]]></search>
    <add position="replace"><![CDATA[
        <button type="button" style="width:50%;" data-toggle="tooltip" title="<?php echo $button_compare; ?>" onclick="compare.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>
    ]]></add>
</operation>    
</file>

 

remove_add_to_cart_category.PNG

 

Remove the Add-To-Cart button from the search page:

<file path="catalog/view/theme/*/template/product/search.tpl">
        <operation>
            <search><![CDATA[<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>]]></search>
            <add position="replace"><![CDATA[
                <button type="button" style="display:none;" onclick="cart.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[<button type="button" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>]]></search>
            <add position="replace"><![CDATA[
                  <button type="button" style="width:50%;" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>
            ]]></add>
        </operation>
        <operation>
            <search><![CDATA[<button type="button" data-toggle="tooltip" title="<?php echo $button_compare; ?>" onclick="compare.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>]]></search>
            <add position="replace"><![CDATA[
                <button type="button" style="width:50%;" data-toggle="tooltip" title="<?php echo $button_compare; ?>" onclick="compare.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>
            ]]></add>
        </operation>    
    </file>

 

rem_add_to_cart_search.PNG

 

Remove the Shopping cart link and button from the header:

<file path="catalog/view/theme/*/template/common/header.tpl">
<operation>
    <search><![CDATA[<li><a href="<?php echo $shopping_cart; ?>" title="<?php echo $text_shopping_cart; ?>"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $text_shopping_cart; ?></span></a></li>]]></search>
    <add position="replace"><![CDATA[
        <li style="display:none;"><a href="<?php echo $shopping_cart; ?>" title="<?php echo $text_shopping_cart; ?>"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $text_shopping_cart; ?></span></a></li>
    ]]></add>
</operation>
<operation>
    <search><![CDATA[<div class="col-sm-3"><?php echo $cart; ?></div>]]></search>
    <add position="replace"><![CDATA[
        <div class="col-sm-3" style="display:none;"><?php echo $cart; ?></div>
    ]]></add>
 </operation>  
 </file>   
 

rem_shopping_cart_header.PNG

 

Keep in mind that all of the code snippets have to be after the <code>isenselabs_hide_add_to_cart</code> line and before the closing </modification> tag. If you want to remove the Add-to-Cart button not from all, but just from some of the previously mentioned places, include just the corresponding code snippets.

4. Save and upload the file through your Extension Installer in Admin Panel => Extensions => Installer. Then go to Extensions=>Modifications and Refresh them by clicking the refresh button.  

Remove Add-to-Cart button Code

 

​Remove the Product Prices

In order to remove the prices of your products, you will need to complete the same steps as before, but change the code in the OCmod file.

1. Start by creating an OCmod file and naming it as nameofyoupreference.ocmod.xml. 

2. Copy and paste the following code snippet with the opening and closing tags:

<modification>
    <name>Hide Product Price</name>
    <version>1.0</version>
    <link>https://isenselabs.com</link>
    <author>iSenseLabs</author>
    <code>isenselabs_hide_product_price</code>
    
​    {body}    

</modification>

 

*The CODE of each modification has to be unique, so make sure that the name within the <code></code> tags is not used. Also note, that if you are uploading the modification more than once, you will have to first delete the old modification, CLEAR the modifications and only afterwards upload the new one.​

3. Replace the {body} with the following codes in order to:

Remove the Product and the Option Price from the product page:

<file path="catalog/view/theme/*/template/product/product.tpl">
<operation>
    <search><![CDATA[<?php if ($price) { ?>]]></search>
    <add position="before"><![CDATA[
        <div style="display:none">
   ]]></add>
</operation>
<operation>
    <search><![CDATA[ <div id="product">]]></search>
    <add position="before"><![CDATA[
     </div>
    ]]></add>
</operation>    
<operation>
    <search><![CDATA[<?php foreach ($option['product_option_value'] as $option_value) { ?>]]></search>
    <add position="after"><![CDATA[<?php unset($option_value['price']); $option_value['price'] ="";?>]]>
    </add>
</operation>
<operation>
    <search><![CDATA[<p class="price">]]></search>
    <add position="replace"><![CDATA[<p class="price" style="display:none;">]]>
    </add>
</operation>    
</file>

 

remove_price_product.PNG

 

Remove the Product Price from the category page: 

<file path="catalog/view/theme/*/template/product/category.tpl">
<operation>
    <search><![CDATA[<p class="price">]]></search>
    <add position="replace"><![CDATA[<p class="price" style="display:none;">]]>
    </add>
</operation>        
</file>

 

 remove_price_category.PNG

 

Remove the Product Price from the search page:

<file path="catalog/view/theme/*/template/product/search.tpl">
<operation>
   <search><![CDATA[<p class="price">]]></search>
   <add position="replace"><![CDATA[<p class="price" style="display:none;">]]>
    </add>
</operation>        
</file>

 

 remove_price_search.PNG

4. Save and upload the file through your Extension Installer in Admin Panel => Extensions => Installer. Then go to Extensions=>Modifications and Refresh them by clicking the refresh button.

 

Remove Price Code

 

We hope that you will find this tutorial easy and helpful. Stay tuned for more tips, tricks and tutorials for OpenCart 2.0.x.

Join 11,000+ subscribers receiving actionable E-commerce advice

* Unsubscribe any time
comments powered by Disqus