How to Add Woocommerce Product Enquiry form For Free?

Sometimes you need a simple enquiry form on your site. There are lots of premium and free plugins available for this but why install another plugin if you already have a contact form on your site? Therefore, in this post you will learn how to add your own contact form on a WooCommerce single product page and use it as an enquiry form.

Video: How to Add Woocommerce Product Enquiry form on the Single Product pages?

Step 1: create a contact form

In the video I am using the Fluent Forms plugin which is a simple to use and offers lots of great features. You can use whatever contact form plugin you like but there is one important thing to keep in mind.

If you would like the enquiry form to show you the product name and URL then you need your form to be able to add hidden fields and embed “post title” or “permalink” data.

See the screenshot below.

How to Add Woocommerce Product Enquiry form For Free?

Step 2: Copy the code to the Code snippets code box

Code Snippets plugin is a free plugin which allows your to run PHP/HTML/CSS/JavaScript code snippets on your site without the need to modify functions.php. The plugin can be found here.

If you are comfortable editing your theme’s function.php file then you can paste the code there.

Now grab the code here below and paste it to the code snippets code box and press on Save and activate button.

Oh, one more thing – before that you may want to change the button text and add something Ask for a price or something else instead of “Send use your enquiry”.

Code snippet used in the video

// Adds a enquiry form on your Woocommerce Single product page
 
add_action( 'woocommerce_single_product_summary', 'enquiry_form', 30 );
function enquiry_form() {
echo '<button type="submit" id="trigger_cf" class="single_add_to_cart_button button alt">Send us your enquiry</button>';
echo '<div id="product_inq" style="display:none">';
echo do_shortcode('[fluentform id="1"]');
echo '</div>';
}
 
add_action( 'woocommerce_single_product_summary', 'enquiry_form_1', 40);
function enquiry_form_1() {
  ?>
    <script type="text/javascript">
        jQuery('#trigger_cf').on('click', function(){
        if ( jQuery(this).text() == 'Send us your enquiry' ) {
                    jQuery('#product_inq').css("display","block");
            jQuery("#trigger_cf").html('Close');
        } else {
            jQuery('#product_inq').hide();
            jQuery("#trigger_cf").html('Send us your enquiry');
        }
        });
    </script>
    <?php    
}

How to Show Woocommerce Product Enquiry form For a Specific Category?

For example, lets imagine that I want to show the form only for products in Clothing category. In order to accomplish that I modify the code above by adding this piece of code below.

if ( has_term( 'clothing', 'product_cat' ) ) {

Just replace the category slug “clothing” accordingly. So the full code for the Clothing category form is:

add_action( 'woocommerce_single_product_summary', 'enquiry_form', 30 );
function enquiry_form() {
	if ( has_term( 'clothing', 'product_cat' ) ) {
echo '<button type="submit" id="trigger_cf" class="single_add_to_cart_button button alt">Send us your enquiry</button>';
echo '<div id="product_inq" style="display:none">';
echo do_shortcode('[fluentform id="1"]');
echo '</div>';
}
}
add_action( 'woocommerce_single_product_summary', 'enquiry_form_1', 40);
function enquiry_form_1() {
  ?>
    <script type="text/javascript">
        jQuery('#trigger_cf').on('click', function(){
        if ( jQuery(this).text() == 'Send us your enquiry' ) {
                    jQuery('#product_inq').css("display","block");
            jQuery("#trigger_cf").html('Close');
        } else {
            jQuery('#product_inq').hide();
            jQuery("#trigger_cf").html('Send us your enquiry');
        }
        });
    </script>
    <?php    
}

Now, let’s imagine that I need two different forms for my products. One is for category Clothing and other one is shown for every other product. Therefore, I modify the code a bit like this on here below.

add_action( 'woocommerce_single_product_summary', 'enquiry_form', 30 );
function enquiry_form() {
	if ( has_term( 'clothing', 'product_cat' ) ) {
echo '<button type="submit" id="trigger_cf" class="single_add_to_cart_button button alt">Send us your enquiry</button>';
echo '<div id="product_inq" style="display:none">';
echo do_shortcode('[fluentform id="1"]');
echo '</div>';
} 
else {
echo '<button type="submit" id="trigger_cf" class="single_add_to_cart_button button alt">Send us your enquiry</button>';
echo '<div id="product_inq" style="display:none">';
echo do_shortcode('[fluentform id="2"]');
echo '</div>';
}
}
add_action( 'woocommerce_single_product_summary', 'enquiry_form_1', 40);
function enquiry_form_1() {
  ?>
    <script type="text/javascript">
        jQuery('#trigger_cf').on('click', function(){
        if ( jQuery(this).text() == 'Send us your enquiry' ) {
                    jQuery('#product_inq').css("display","block");
            jQuery("#trigger_cf").html('Close');
        } else {
            jQuery('#product_inq').hide();
            jQuery("#trigger_cf").html('Send us your enquiry');
        }
        });
    </script>
    <?php    
}

How to remove Woocommerce add to cart button?

Take a look at the code below. If you don’t need Add to cart buttons on your site and just need an enquiry form then paste this code to the Code Snippets code box. Please read the explanations after every function.

If you do not want to remove the add to cart button from your site then there is no need for this code here.

add_filter( 'woocommerce_is_purchasable', '__return_false'); // DISABLING PURCHASE FUNCTIONALITY AND REMOVING ADD TO CART BUTTON FROM NORMAL PRODUCTS
 
remove_action('woocommerce_single_variation', 'woocommerce_single_variation', 10); // REMOVING PRICE FROM VARIATIONS
 
remove_action('woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20); // REMOVING ADD TO CART BUTTON FROM VARIATIONS
 

Useful tips

Here are some of my favorite Wordpress tools

Thank you for reading this article. I hope you found it helpful as you build your own websites and e-commerce sites. Here are some tools I use as a Wordpress developer and enthusiast that I hope you’ll also find helpful.

These are affiliate links, so if you do decide to use any of them, I’ll earn a commission and this helps me create these tutorials and make Youtube videos. But in all honesty, these are the exact tools that I use and recommend to everyone, even my friends and family.

Themes: For the last couple of years I have two go-to themes which I use for every kind of projects. Those two themes are Blocksy theme and Kadence Theme. On this site and my Youtube channel you’ll see a lot of tutorials I have made about them. If you would like to get a 10% discount for both of them then:

Contact forms: There are hundreds of contact forms out there but Fluent Forms is the one I like the most. If you need a 20% discount then use this link (save 20% coupon is WPSH20).

Gutenberg add-ons: If I need a good Gutenberg blocks add-on then Kadence Blocks is the one I have used the most. You’ll get 10% discount with the coupon SIMPLEHACKS here.

Website migration: While building a website you probably need a good plugin that can help you with the migration, backups, restoration and staging sites. Well, WpVivid is the one I have used for the last couple of years. If you use this link along with the WPSH20 coupon you’ll get 20% discount.

Woocommerce extensions: There are a bunch of Woocommerce extensions that I really like but the one that stands really out is Advanced Dynamic Pricing. Once again, you’ll get a 20% discount if you use this link here (save 20% coupon is WPSH20)

Web Hosting: For getting started, I really like A2 Hosting. They have the dedicated and fast Wordpress hostinh and support has also been fast and responsive. If you’re more tech savvy and want to have a really fast managed cloud hosting then I recommend Cloudways. (Btw, this site is hosted in Cloudways.)

To see all my of most up-to-date recommendations, check out this resource that I made for you!

Do you want to thank me and buy me a beer?

Every donation is entirely welcome but NEVER required. Enjoy my work for free but if you would like to thank me and buy me a beer or two then you can use this form here below.

Choose amount

Best selling plugins

Default image
Janek T.
I am a Wordpress enthusiast who has been making websites since 2011. In this site I am offering simple to follow tips on how to use Wordpress and Woocommerce. If you want to be the first to be notified about the new tutorials then please subscribe to my Youtube channel here Follow me in Twitter here
Articles: 72