"Call for Price" on Products Without a Price
Shows a "Call for price" link instead of a blank space when a product has no price set, so shoppers know how to get a quote.
Opens WPIDE on
Code
add_filter( 'woocommerce_empty_price_html', function ( $html, $product ) {
$label = 'Call for price'; // Link text.
$phone = '+1 555 010 0000'; // Your phone number.
return sprintf( '<a class="wpide-call-for-price" href="%s">%s</a>', esc_url( 'tel:' . preg_replace( '/[^0-9+]/', '', $phone ) ), esc_html( $label ) );
}, 10, 2 );
Notes
Set $phone to your number, or change the link to a contact page URL.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.