Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created January 12, 2012 01:40
Show Gist options
  • Save mikejolley/1597957 to your computer and use it in GitHub Desktop.
Save mikejolley/1597957 to your computer and use it in GitHub Desktop.
WooCommerce - Replace '' with 'Call for price' when price is left blank
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_empty_price_html', 'custom_call_for_price');
function custom_call_for_price() {
return 'Call for price';
}
@tnog
Copy link

tnog commented Mar 22, 2013

Thanks, works like a charm.

@kukac7
Copy link

kukac7 commented Apr 10, 2013

you can solve it than do product variations in the "From" price into the "Call for price", but actually place the price?

@alshedupur
Copy link

Works! Really Thanks. Works with function.php in themeforest The Retailer themes.

@silentfxx
Copy link

Does this work for WooCommerce 2.0.19? I have a test site and it doesn't seem to work.

@dnordyke
Copy link

Worked for me on WP 3.9.1 and WooComm 2.1.8. I added the code above to line 17 of /woocommerce/includes/wc-template-hooks.php.

@roman-bytes
Copy link

this works for me but it wont show on the front-end of the site. When viewing products in the list I can see the price says Call for Price. Any suggestions as to what might be preventing it from showing?

@sevekim
Copy link

sevekim commented Feb 17, 2015

Hi.

I have a question.

So, users can write something like "contact me directly" or "call for price" directly into the price field.
Here is what I am trying to achieve:

When an user puts non-numeric character in price field, then regardless of what they have written, I want to show "Contact the seller" on the product page.

Would you happen to know how I can do this?

Thank you

@ucozlab
Copy link

ucozlab commented Mar 12, 2016

dnordyke thanx a lot!!! I was searching how to do that about 2 hours, and after changing this file it really works!

@Remcovanharten
Copy link

Thank you! Works perfectly with Enfold v3.5.4 & WooCommerce v2.5.5.

@buckneri
Copy link

um but they can still add it to cart... and buy it for free...

@MarcusFuto
Copy link

I am using the code for showing SOLD products. How could I create "Request a price" when setting price to 0?

@marketfreshstudios
Copy link

This works great except for products with variations.
How can we make this work for the variants as well?

@Spuft
Copy link

Spuft commented Aug 20, 2018

Thanks!! It worked for me, WC 3.4.4, 'Request for price' is more professional but anyway, thank you!

@tranthaihoang
Copy link

Good! thank, work for me

@huynhthaihung2765
Copy link

Good men! thanks

@opAnLe
Copy link

opAnLe commented Nov 4, 2019

Hi,
can you advice how to create the same if you use WPML and need to have the text translated in 3 languages?

@mabnawp
Copy link

mabnawp commented May 30, 2020

Works! Really Thanks/

@Alexander-Pop
Copy link

Alexander-Pop commented Sep 14, 2020

For variable product use woocommerce_variable_empty_price_html //woocommerce/includes/class-wc-product-variable.php
for grouped products use woocommerce_grouped_empty_price_html //woocommerce/includes/class-wc-product-grouped.php

@lalonhossain
Copy link

Thanks Mike for your code. It really works!!!

@mikejd300
Copy link

For variable product use woocommerce_variable_empty_price_html.
for variation product use woocommerce_variation_empty_price_html

I don't think that's clear. There is no variable vs variation product.

To clarify, it's either a variable product or a variation of a product (a variation is not a product).

@masvil
Copy link

masvil commented Jun 17, 2021

Works great, thank you!

@petefleming33
Copy link

Reverts to 0.00 when currency changed.

Is there a fix for this?

@slimmziy
Copy link

Works for Nitro theme

@sumera22
Copy link

sumera22 commented Apr 4, 2022

hi Micheal, your code works for me. Thank you. Can you help me if i want to add "href=tel:xxxxxxx" option on Call for price? how can i add it in this code...? will appreciate your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment