Posted on

WooCommerce: POA / Call for Price Button @ Single Product Page

This has been on my to-write list for a looooooong while! You might want to show a “POA” or “Call for Price” when you have a product with no price. Many businesses require this, mostly real estate and wholesalers. So let’s see how it’s done ๐Ÿ™‚

WooCommerce POA

PHP Snippet: Display “POA” & enquiry button for blank price products @ WooCommerce Single Product Page

Before taking a look at the snippet, make sure your “POA” product has no price (regular and sale price). Also, please reference to this other article if you want to add some Javascript to show/hide a Contact Form 7: https://businessbloomer.com/woocommerce-show-inquiry-form-single-product-page-cf7/


/**
 * @snippet       Display "POA" for blank price products @ WooCommerce Single Product
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=22158
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.3.3
 */

add_filter('woocommerce_empty_price_html', 'bbloomer_poa_and_enquiry_cf7_woocommerce');

function bbloomer_poa_and_enquiry_cf7_woocommerce() {
	$html = '<div class="poa">POA</div>';
	$html .= '<button type="submit" id="trigger_cf" class="single_add_to_cart_button button alt"> Request Price Now </button>';
	$html .=  '<div id="product_inq" style="display:none">';
	$html .= do_shortcode('[paste_your_contact_form_7_shortcode_here]');
	$html .=  '</div>';
	return $html;
}

// To show Contact Form 7 on Button Click event check:
// https://businessbloomer.com/woocommerce-show-inquiry-form-single-product-page-cf7

Where to add this code?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Does this snippet still work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert, WordCamp speaker and Internet marketer, Rodolfo Melogli has worked as a WooCommerce freelancer since 2011. He helps entrepreneurs and developers overcome their WooCommerce nightmares :) Rodolfo is the organiser of WordCamp Dublin, the Dublin WooCommerce Meetup, the Dublin Ecommerce Meetup and the Dublin WordPress Meetup. He enjoys interacting with people, travelling and chasing tennis & soccer balls. Of course, he loves pizza too.

24 thoughts on “WooCommerce: POA / Call for Price Button @ Single Product Page

  1. Can the code $html .= do_shortcode(‘[paste_your_contact_form_7_shortcode_here]’); be amended to a phone line like:
    $html .= do_shortcode(‘<a href="tel:[$phone];"Call to Order‘); or something to that effect. Forgive my unrelated code entry syntax.

    Then, on the single product admin page, have an additional field to put in a phone number in this type of format: +5551234567

    That way if a different Dept or Section for each individual product would be called, instead of a single generic number. Make sense?

    1. Hello Roberta, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  2. Hi,
    I have just inserted your code, add a Contact 7 form and then went to the front end and clicked on ‘Request Price’ but nothing happens.

    Contact form short code: contact-form-7 id=”63″ title=”Contact form 1″ and I tried contact-form-7 id=”63″

    I have obviously pasted something wrong! ๐Ÿ™‚

    1. Hey Rob, thanks so much for your comment! I just retested this on the latest version of WooCommerce and it still works. Unfortunately this looks like custom troubleshooting work and I cannot help here via the blog comments. Thanks a lot for your understanding! ~R

    2. Hi Rodolfo,

      Thanks for the response. I am not sure what you mean about customerisation as there isn’t any.

      I have just switched to 2015 theme and it still doesn’t work.

      see here: https://synaxissolutions.co.uk/2018/product/testing-testing/

      AS I said maybe I have not completed what is required, but I have pasted the coding into functions.php of 2015

      See here: https://screencast.com/t/PpV3zWH5Np7c

      and I have all plugins deactivated,. see here: https://screencast.com/t/MDFsnpIu2bT

      If it all still works, can you tell me under which theme it works, and I wil debug from there.

      Thanks

    3. Hi,

      I have tested further and managed to get the ‘Requset More detail’ working, but now the ‘Request More Detail’ button does not disappear when I add in price.

      See here: https://synaxissolutions.co.uk/2018/product/epilson-e9-83-twin-controls/

      has price and request more details. See here:https://screencast.com/t/3t7YMofow

      Maybe I have misunderstood the functions.php?

    4. Hey Rob, this should work. Sorry but I can’t provide complementary troubleshooting here via the blog comments – thanks for your understanding ๐Ÿ™‚

  3. Is there a way to restrict this to alter just the price of the product on the product page itself? At present, it shows for the price on related products below the product page and on recently viewed products in the sidebar also

    I’ve tried using “if ( is_product() ) {…” and while this stops the button appearing on the shop / category pages, it displays everywhere (active product, related and recent) once in a product page

    Thanks in advance

    1. Hiya Conor, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  4. Love the article, thanks it helps a lot, my only issue is that i dont use contact form 7, i use Caldera Forms and the short code does not work. any adjustment in code to achieve this?

    1. Hey Wesley, if you change the shortcode it should work out of the box. Make sure the shortcode is written properly and that you keep the single quotes before and after.

    2. Hi Rodolfo, i got your code right, but the only problem is that it shows on pages that have prices too. I have not adjusted your code, other than the label and the short code. So even if there is a price, it still shows up.

    3. Never mind, i am being a tonsil ๐Ÿ™‚ I didnt change the action name.

      But it still shows up on the category page, with the button and does nothing when you click on it. I wish i had a programming mind like yours ๐Ÿ™

    4. hey Wesley, thanks for your comment! I suggest you take a look at “conditional logic”: https://businessbloomer.com/conditional-logic-woocommerce-tutorial/ and https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Let me know ๐Ÿ™‚

  5. Thanks a lot Rodolfo, happens to be just what I was looking for today!

    1. Brilliant ๐Ÿ™‚

  6. Hello,

    I’m currently working on an ecommerce for a client, using the Woocommerce Storefront theme (editing on child theme version). Right now, I’m trying to display text instead of not showing the product price when left blank. I’ve been looking for a solution to this problem for a while. Im happy I found the code you’ve provided, however no changes or error appeared on the website. Any recommendations?

    1. Hey Allegra, thanks for your comment! This should work when the price is left blank – you have “blank” prices or “zero” prices?

    2. Right now I have some products with and without pricing. The products without pricing are left blank.

    3. Can you try switching to “Twentyseventeen” theme and let me know if the snippet works in that case?

  7. Hello Rodolfo,

    We are also using this snippet.
    Do you have an example ‘code’ to disable the buttons on the shop pages?
    We don’t know how to complete this code.

    Also, we integrated a Contact Form 7.
    The title of the product is showing in the ‘subject’ field.
    But in this subject field, there is html code showing. > –
    Anyway we can hide this? Besides deleting this from every product.

    Example: Josval – FILTRO FES-22000 – Microfilter 22000 l/m

    1. Hey Luuk, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here on the blog. Thanks a lot for your understanding! ~R

  8. Hi Rodolfo,
    I added this snippet and all works fine. Except the “POA” and “Request Price” button is also showing on the shop pages?
    Is there any way to exclude this from showing on the pages?

    1. Hey Cathy ๐Ÿ™‚ Yes, of course. Inside the function, use:

      function blablabla() {
      if ( is_product() ) { 
      // run function 
      }
      }
      

      This is called “conditional logic”: https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/

Questions? Feedback? Support? Leave your Comment Now!
If you're writing code, please wrap it between: [php] code_here [/php]

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.