Virtina

Virtina

STRATEGIZE . OPTIMIZE . SOLVE

Call
  • About Us
  • Solutions
    • By Platform

      • WordPress
      • WooCommerce
      • Magento
      • BigCommerce
      • Shopify
      • Wix
      • Odoo
      • Volusion
      • PrestaShop
      • Vtex
      • OpenCart
      • 3dCart
    • By Industry

      • Manufacturing / B2B
      • Retail
      • Food & Beverages
      • Fashion & Apparel
      • Jewelry
      • Electrical & Electronics
      • Medical & Healthcare
      • Automotive
      • CBD
    • By Service

      • Strategy
      • Roadmap
      • Prototyping
      • Platform Selection
      • Design
      • Development
      • Replatform
      • Integration
      • Core Web Vitals
      • Page Speed Optimization
      • Performance Optimization
      • CRO
      • SEO
      • Data Backup
      • Support
  • Portfolio
  • Resources
      • Blog
      • eCommerce News
      • eCommerce Tips
      • Project News
      • Case Studies
      • Success Stories
      • Events
      • Extensions
      • Partners
      • Affiliate Program
      • Videos
      • Tools
        • Cost Calculator
        • ROI Calculator
        • CRO ROI Calculator
      • FAQ
  • Clients
      • Agencies
      • Direct Clients
      • SaaS
  • Hire Us
    • Development

      • Hire WooCommerce Developer
      • Hire Magento Developer
      • Hire BigCommerce Developer
      • Hire Shopify Developer
    • Migration

      • Migrate to WooCommerce
      • Migrate to Magento
      • Migrate to BigCommerce
      • Migrate to Shopify
  • Contact us

CONTACT US

(888) 478-4799

sales@virtina.com

How to Hide “Add to Cart” Button on Your WooCommerce Store Without Plugins?

Hide "Add to Cart" Button on WooCommerce
  • facebook Share
  • twitter Tweet
  • linkedin Recommend
  • pinterest Pin

If you are running an eCommerce business, then you will surely at some point want to remove or hide the "Add to Cart" button on your store. There are a number of reasons or situations that may demand you to hide or remove the "Add to Cart" button on your store.

Many WooCommerce store owners have come to us asking how they can do the same in their store, so we have decided to write an article on how to hide or remove the "Add to Cart" button on your WooCommerce store.

Why Hide or Remove the “Add to Cart” Button on Your WooCommerce Store?

As I mentioned before, the decision to remove or hide the "Add to Cart" button either temporarily or permanently can be due to a number of reasons.

Out of Stock Products

One of the most commonly seen reasons for removing the "Add to Cart" button on a store is that the product is out of stock.

Unavailable or Discontinued Products

The "Add to Cart" button is often removed on products that are no longer sold on the website. Some websites choose not to take down the product entirely in case it may become available again in the store.

Sales Strategy

The eCommerce stores also choose to hide or remove the "Add to Cart" button in case a product is running low on stock but is high in demand. The product is made available to the public by enabling the "Add to Cart" button again as part of a sales strategy.

Hiding or Removing the "Add to Cart" Button on Your WooCommerce Store

You can hide or remove the 'Add to Cart" button on your WooCommerce store either using a plugin or with a simple code. Most developers prefer to use a code to implement this, and although this can be done via CSS, JS, or PHP, the most preferred choice is often the PHP.

How to Hide/Remove the "Add to Cart" Button?

WooCommerce offers you a number of hooks that you can use to remove buttons on your WooCommerce site or even remove the prices if you want. One of the best things about the hooks shown above is that they can be used anywhere as long as it's appropriate there.

Although the most common practice involves using the hooks in the theme folder under functions.php, it is not ideal as it can cause errors.

Remove "Add to Cart" Button Via woocommerce.php

So where else can we do? Where is it best to use the WooCommerce hook so that you can remove the "Add to Cart" button? The answer lies in the plugin folder, where you can find the woocommerce.php file.

Steps to Reach woocommerce.php and Applying the Hooks

WordPress → wp-content → plugins → woocommerce → woocommerce.php

Remove "Add to Cart" Button Via woocommerce.php

Once you have navigated yourself to woocommerce.php, following the steps given above, you can use the hooks here for removing the "Add to Cart" button from your WooCommerce store. Given below is the hook you can utilize to remove the "Add to Cart" button from your WooCommerce store.

remove_action( 'woocommerce_after_shop_loop_item',

 'woocommerce_template_loop_add_to_cart');


remove_action( 'woocommerce_single_product_summary',

 'woocommerce_template_single_add_to_cart');

After applying the hooks, all you have to do is save the file and refresh the page. If everything has gone well, then the "Add to Cart" button must be removed now. However, if you are noticing some error, you need not worry about it because we'll explain what you can do if that is the case.

Remove "Add to Cart" Button Via Filter

The "Add to Cart" button can also be removed using a simple filter. If you look for it, you'll notice the following code in your WooCommerce store.

global $product;

if ( ! $product->is_purchasable() ) {

    return;

}

The purpose of the code given above is to display the "Add to Cart" button as long as the filter "is_purchasable" is set to true else the button is hidden. It would be best if you also kept in mind that the above code is run before any functionality check. The solution here is pretty evident, and all you have to do is add a simple line of code.

add_filter( 'woocommerce_is_purchasable', '__return_false');

By adding the code above, you can render the product unpurchasable. However, the best part is that it has no compatibility issues, and neither does it remove any hooks or templates.

Remove the "Add to Cart" Button for Specific Products

More often than not, you would want to hide the "Add to Cart" button for a specific product, and three methods can accomplish this.

  1. The easiest way to hide the "Add to Cart" button is to remove the figure from the products price field simply. Removing the price would automatically mean that it can not be purchased and, consequently, removes the "Add to Cart" button.
  2. The next thing you can do is to enable stock management. By doing so, you'll be able to set the product stock on your WooCommerce store. Setting the stock to zero also accomplishes what you need and removes the "Add to Cart" button.
  3. The third option employs a much more precise method, where we make use of a filer for the woocommerce_is_purchasable hook. The filter detects the product ID of the product in question and returns a false value. This enables you to display the product with the price but shows a notice that says, "Product can not be purchased."

To implement the last option, all you have to do is access functions.php inside the theme folder and add the code given below.

add_filter('woocommerce_is_purchasable', 'woocommerce_cloudways_purchasable');

function woocommerce_cloudways_purchasable($cloudways_purchasable, $product) {

return ($product->id == your_specific_product_id (like 22) ? false : $cloudways_purchasable);

}

Conclusion

The "Add to Cart" button is often removed for various reasons, and WooCommerce store owners must be proficient in doing it whenever it's necessary. The "Add to Cart" button may be removed for all the products or specific products depending on the business's requirement.

  • facebook Share
  • twitter Tweet
  • linkedin Recommend
  • pinterest Pin

Any questions?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

virtina icon
(888) 478-4799 hello@virtina.com
(514) 613-5073 hello@virtina.com
+61282942073 hello@virtina.com

eCommerce tips sign up

We'll never share your email

WHAT WE OFFER

WooCommerce

  • WooCommerce Development
  • Certified WooCommerce Experts
  • WooCommerce Migration
  • WooCommerce Customization
  • WooCommerce Plugin Development
  • Custom WooCommerce Themes

BigCommerce

  • BigCommerce Development Services
  • BigCommerce Website Design
  • BigCommerce Theme Development
  • Migrate to BigCommerce
  • Bigcommerce Customization Services
  • BigCommerce Plugin Development

Magento

  • Magento Web Development
  • Magento Expert Developers
  • Magento 2 Migration
  • Magento eCommerce Store
  • Custom Magento Development
  • Magento Extension Development

Shopify

  • Shopify Development Experts
  • Shopify Integration
  • Shopify Store Migration
  • Shopify Theme Development
  • Shopify Theme Customization
  • Certified Shopify Developer

Top eCommerce Articles

  • Platform Migration in eCommerce
  • Top eCommerce Platforms
  • eCommerce Failure Reasons
  • Multi-vendor WooCommerce Plugins
  • WooCommerce Subscriptions Migration
  • Core Web Vitals in eCommerce

Odoo

  • Odoo Development

Volusion

  • Volusion Experts

3dCart

  • 3dCart Websites
  • Twitter
  • Facebook
  • Instagram
  • Pinterest
  • Linked In
  • Privacy Policy
  • Website Terms
  • Terms & Conditions
  • Sitemap
Copyright © 2009 - 2022 Virtina. All rights reserved.
  • About Us
  • Solutions
    • By Platform

      • WordPress
      • WooCommerce
      • Magento
      • BigCommerce
      • Shopify
      • Wix
      • Odoo
      • Volusion
      • PrestaShop
      • Vtex
      • OpenCart
      • 3dCart
    • By Industry

      • Manufacturing / B2B
      • Retail
      • Food & Beverages
      • Fashion & Apparel
      • Jewelry
      • Electrical & Electronics
      • Medical & Healthcare
      • Automotive
      • CBD
    • By Service

      • Strategy
      • Roadmap
      • Prototyping
      • Platform Selection
      • Design
      • Development
      • Replatform
      • Integration
      • Core Web Vitals
      • Page Speed Optimization
      • Performance Optimization
      • CRO
      • SEO
      • Data Backup
      • Support
  • Portfolio
  • Resources
      • Blog
      • eCommerce News
      • eCommerce Tips
      • Project News
      • Case Studies
      • Success Stories
      • Events
      • Extensions
      • Partners
      • Affiliate Program
      • Videos
      • Tools
        • Cost Calculator
        • ROI Calculator
        • CRO ROI Calculator
      • FAQ
  • Clients
      • Agencies
      • Direct Clients
      • SaaS
  • Hire Us
    • Development

      • Hire WooCommerce Developer
      • Hire Magento Developer
      • Hire BigCommerce Developer
      • Hire Shopify Developer
    • Migration

      • Migrate to WooCommerce
      • Migrate to Magento
      • Migrate to BigCommerce
      • Migrate to Shopify
  • Contact us
Let's Connect

You are scheduling a meeting with

Give us a call or email anytime, we endeavour to answer all enquiries as quick as possible.

What is 6+1?

Let's Connect

Talk to Jim Gregg, our Head of Operations

What is 1+4?

virtina-logo
CUSTOMIZED PLANS

Start improving your organic search engine rankings and revenues with us! Need an eCommerce SEO strategy that's customized for your unique business and its requirements?

What is 9+2?

Let's Connect

Talk to Elliot Levy, our Head of Delivery

What is 9+2?

Let's Connect

What is 7+4?

Platform Migration

What is 7+7?

Download PDF

What is 1+4?

What is 1+4?

What is 7+4?

GET STARTED WITH STENCIL THEME DEVELOPMENT

What is 9+2?

Let's Connect

What is 6+1?