OhhMuaOhhMua
  • Home
  • Hosting
    • Best Web Hosting
    • Free Web Hosting
    • VPS Hosting
  • WordPress
    • Solutions & Troubleshooting
    • Installation & Setup
    • Themes & Plugins
    • Security
  • Computer Tips
    • Gaming Errors & Solutions
    • PC Troubleshooting
    • Computer Hardware
  • Coupons & Deals
  • Contact Us
Reading: Change 0 Price or Empty Price to ‘Call for Price’ in WooCommerce
Share
Notification Show More
Font ResizerAa
OhhMuaOhhMua
Font ResizerAa
  • Computer Tips
  • Hosting
  • WordPress
Search
  • Home
  • WordPress
    • Installation & Setup
    • Security
    • Solutions & Troubleshooting
    • Themes & Plugins
    • Troubleshooting
  • Hosting
    • Free Web Hosting
    • VPS Hosting
    • Best Web Hosting
  • Computer Tips
    • PC Troubleshooting
    • Gaming Errors & Solutions
    • Computer Hardware
  • Coupons & Deals
Have an existing account? Sign In
Follow US
Copyright © 2024 ohhmua. All rights reserved.
OhhMua > Blog > WordPress > Solutions & Troubleshooting > Change 0 Price or Empty Price to ‘Call for Price’ in WooCommerce
Solutions & Troubleshooting

Change 0 Price or Empty Price to ‘Call for Price’ in WooCommerce

ohhmua
Last updated: September 8, 2024 6:16 am
ohhmua
Share
2 Min Read
Change 0 Price or Empty Price to 'Call for Price' in WooCommerce
Change 0 Price or Empty Price to 'Call for Price' in WooCommerce
SHARE
Contents
Code Explanation:Conclusion:

If you want to change the price of 0 or leave the price field empty to display “Call for price” in WooCommerce, you can refer to the code below.

Code to Change 0 Price or Empty Price to “Call for Price” in WooCommerce

You can add the following code to the functions.php file of your child theme:

add_filter('woocommerce_get_price_html', 'custom_empty_price_message', 10, 2);
function custom_empty_price_message($price, $product) {
    if ($product->get_price() === '' || $product->get_price() == 0) {
        $price = '<span class="webantam-woocommerce-price-contact">Call for Price</span>';
    }
    return $price;
}

Code Explanation:

  • if ($product->get_price() === ” || $product->get_price() == 0): This conditional statement checks whether the product price is either an empty string (meaning you didn’t enter a price) or if the price is 0.
  • $price = ‘Call for Price’; If the above condition is met, this line replaces the product price with the HTML string <span class="webantam-woocommerce-price-contact">Call for Price</span>. This will display the text “Call for Price” on the WooCommerce product page.

Conclusion:

With just a simple code snippet, you can easily solve the issue of changing a 0 price or empty price to display “Call for Price” in WooCommerce. If you encounter any issues during the process, feel free to reach out!


You Might Also Like

Cannot Fetch Sitemap in Google Search Console

Discovered – Currently Not Indexed in Google Search Console: What It Means & How to Fix It

Why 2 Backlinks per Article Might Be Killing Your SEO

What is Obsidian? Why Developers Love This Note-Taking App

Want Faster Load Times? Optimize WordPress This Way

Share This Article
Facebook Twitter Email Print
Leave a comment Leave a comment

Leave a Reply Cancel reply

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

Trending

Want to Protect Your Website
Security

Want to Protect Your Website? Never Do These 6 Things!

May 23, 2025
Computer Tips

Simple Ways to Minimize Your Computer Screen

August 28, 2020
How to Check Computer Power Supply
Computer Hardware

How to Check Computer Power Supply

July 29, 2023
Contact button
Solutions & Troubleshooting

Contact button in the footer with added call button shake effect

September 21, 2024
Cannot Fetch Sitemap in Google Search Console
Solutions & Troubleshooting

Cannot Fetch Sitemap in Google Search Console

May 27, 2025
What is an SSD
Computer Hardware

[The Truth] What is an SSD? Does an SSD Help You Game Faster?

August 4, 2020
Previous Next

You Might Also Like

My Google Discover traffic skyrocketed after I did these 10 things
Solutions & Troubleshooting

My Google Discover traffic skyrocketed after I did these 10 things

May 14, 2025
How to Add a Read More to Product Descriptions in WooCommerce
Solutions & Troubleshooting

How to Add a “Read More” and “Show Less” Button to Product Descriptions in WooCommerce

May 5, 2025
WordPress Covers Every Website Type
Solutions & Troubleshooting

Blog, E-Commerce, or Forum? WordPress Covers Every Website Type!

April 29, 2025
Optimized Pagination thumbnail
Solutions & Troubleshooting

How I Optimized Pagination and Skyrocketed Traffic

April 28, 2025
Previous Next
newsletter featured

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Follow US on Social Media

Facebook Youtube Steam Twitch Unity

Copyright © 2024 ohhmua. All rights reserved.

OhhMua

Information

  • About
  • Terms & Conditions
  • Privacy Policy
Welcome Back!

Sign in to your account

Lost your password?