Hide the Ninja Forms Add-ons’ prices in the cart and checkout pages


I’ve been asked to write this article to show you how to hide the prices added by Ninja Forms Product Add-ons in the variations table on the checkout and cart page.

This was quite hard (not the code, but the regular expression, i’m a bit noob with regular expressions) but funny!

I chose to hide them with regular expressions. Why?

Well, this code should work with any price format, so different currencies, different amounts, different decimal separators and different number of decimals. So the regular expressions is probably a good choice to match all of them an replace the total price string from the pages.

But now it’s time to show you what to do.

Open, as usual, the file functions.php located in wp-content/themes/your-theme-name/ and add this code at the end of the file:

The patter is explained in the code, it matches the whole amount between the parenthesis, but first removes the HTML added by the plugin.


9 replies
  1. Michael Dunn
    Michael Dunn says:

    This worked a treat. Thanks. Made the mistake of pasting the code outside the closing PHP tag to start with, what a numpty!

  2. Peter
    Peter says:

    Thanks for this code!

    I am having a couple of issues though,

    1) I had to remove the first and last “/” to get it to work (I don’t know why – nobody else mentioned having to do that).

    2) After I pay and get my woocom emails, they don’t have any of the data that was related to the field.
    Also, the woocommerce order doesn’t have the data either. The ninja form does, but the customer gets an email that looks as though they left all their fields blank.

    For example, if the form had a “First name” field the normal output is this:
    First Name: Peter ($0.00)
    After using your code the output SHOULD be:
    First Name: Peter
    but instead is:
    First Name:

    Anyone else having this issue?
    It’s weird because it works correctly when displaying the Cart, but everything else after the purchase is lacking all the data (except for the ninja form submission).

  3. Shannon
    Shannon says:

    I tried adding this to my functions an it doesn’t work. I submitted two tickets to WooCommerce over the last two days and haven’t received a response.

  4. MrP
    MrP says:

    Gday. This worked perfectly as-is. Simply dumped it in functions.php and away went those nasty $0.00s. Any thoughts how I can remove fields that are not completed by customers. No point in those fields appearing either (if there’s no user data in it). This would make the checkout summary & customer order much cleaner. Thanks a ton!

  5. Jonas Vendike
    Jonas Vendike says:

    Hi Nicola

    This code looks awesome and seems to be exactly what some people are looking for.

    Unfortunately, I am looking for a simple modification of the above.

    At http://www.apspartner.dk/product/anpartsselskab we have a long form with 4 parts.

    99% of the fields are just something I need in order to prepare some legal documents, not something the customer wants to look at again before checking out.

    So, I was thinking, is it possible to simply remove the free fields with input and price and everything from the checkout page?

    Hope its possible to find a simple solution that also works.

    Thanks, looking forward to hear from you.



      • Jonas Vendike
        Jonas Vendike says:

        No I didn’t, but a bad fix that works for now, is just removing all ninja forms input in the checkout and thank you table:

        /* Should hide all NinjaForms Fields from Checkout Page*/
        .woocommerce form.checkout table.shop_table .variation{
        display: none;

        /* Hide the variaton from the Thank You Page*/
        .woocommerce-checkout table.shop_table .variation{
        display: none;

        Customers still get a really ugly email though, thats for sure – no body have a fix that could work for the above?


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply