Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created January 12, 2012 01:40
Show Gist options
  • Select an option

  • Save mikejolley/1597957 to your computer and use it in GitHub Desktop.

Select an option

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';
}
@tranthaihoang
Copy link
Copy Markdown

Good! thank, work for me

@huynhthaihung2765
Copy link
Copy Markdown

Good men! thanks

@opAnLe
Copy link
Copy Markdown

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?

@moribarati
Copy link
Copy Markdown

Works! Really Thanks/

@Alexander-Pop
Copy link
Copy Markdown

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
Copy Markdown

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

@mikejd300
Copy link
Copy Markdown

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
Copy Markdown

masvil commented Jun 17, 2021

Works great, thank you!

@petefleming33
Copy link
Copy Markdown

Reverts to 0.00 when currency changed.

Is there a fix for this?

@slimmziy
Copy link
Copy Markdown

Works for Nitro theme

@sumera22
Copy link
Copy Markdown

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