Instantly share code, notes, and snippets.

Embed
What would you like to do?
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';
}
@Ricky1990

This comment has been minimized.

Ricky1990 commented Mar 8, 2013

I've just added this code to functions.php of my theme but it doesn't work. Please test it again and help me. Thank you so much !

@beyondprograms

This comment has been minimized.

beyondprograms commented Mar 14, 2013

works for me. You need to put the code in woocommerce-hooks.php with all of the other hooks. I personally put the hook after the function. Bad past experiences with wordpress has forced this habit.

@tnog

This comment has been minimized.

tnog commented Mar 22, 2013

Thanks, works like a charm.

@kukac7

This comment has been minimized.

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

This comment has been minimized.

alshedupur commented May 19, 2013

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

@silentfxx

This comment has been minimized.

silentfxx commented Nov 19, 2013

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

@dnordyke

This comment has been minimized.

dnordyke commented May 21, 2014

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-II

This comment has been minimized.

roman-II commented Jun 14, 2014

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Remcovanharten commented May 12, 2016

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

@buckneri

This comment has been minimized.

buckneri commented Jun 19, 2016

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

@MarcusFuto

This comment has been minimized.

MarcusFuto commented Apr 7, 2017

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

@marketfreshstudios

This comment has been minimized.

marketfreshstudios commented Apr 23, 2018

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

@Spuft

This comment has been minimized.

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

This comment has been minimized.

tranthaihoang commented Sep 28, 2018

Good! thank, work for me

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