Home » WooCommerce: Product Enquiry Form @ Single Product Page (CF7)

WooCommerce: Product Enquiry Form @ Single Product Page (CF7)

by Tutor Aspire

A client asked to show a “Product Inquiry” button on the Single Product Page which would display, upon click, a Contact Form with an automatically populated subject (Contact Form 7 plugin must be installed of course). Here’s how I did it!

Display Product Enquiry Form on the WooCommerce Single Product Page

PHP Snippet: Add CF7 to the Single Product Page – WooCommerce

 * @snippet       Show CF7 Form @ WooCommerce Single Product
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 5
 * @donate $9     https://www.tutoraspire.com
add_action( 'woocommerce_after_add_to_cart_form', 'tutoraspire_woocommerce_cf7_single_product', 30 );
function tutoraspire_woocommerce_cf7_single_product() {
   echo '';
   echo '';
   wc_enqueue_js( "
$('#trigger_cf').on('click', function(){
if ( $(this).text() == 'Product Inquiry' ) {
$('input[name='your-subject']').val('" . get_the_title() . "');
} else {
$('#trigger_cf').html('Product Inquiry');
   " );

Is There a Plugin For That?

If you’d love to code but don’t feel 100% confident with PHP, I decided to look for a reliable plugin that achieves the same result.

Actually, in this case, I wrote a full tutorial – it covers many plugin alternatives and gives you screenshots and links. Here it is: https://businessbloomer.com/enable-woocommerce-customers-request-quote/

But in case you hate plugins and wish to code (or wish to try that), then keep reading 🙂

You may also like