Pre-filled product inquiry form with Gravity Forms and WooCommerce




Screencasts – WP Theme Tutorial show

Summary: Today we’re going to conitue from last weeks screencast on removing the purchase button from all products inside a category. It was great to get the button removed but makes the page almost totally useless. Now we’re going to take a Gravity Forms form and add it to our page so that users can fill out the form and inquire about the product. Setting up the form To start with we need to set up our form with the fields we need. I have mine set to ask for the name, email, phone number. It also provides a textarea for the site user to ask their question. The final field is called product name and we’re going to dynimically populate it with the name of the product that is currently on the page. Asking the customer to fill out that extra bit of information is just sucky so we’ll do it for them. Under the field advainced tab you need to check off “Allow field to be populated dynamically” and then you need to enter a parameter. We’ll use ‘west_boat_name’. The parameter is just a way for Gravity Forms to be able to reference the field for our dynamic population. Adding the form to our product Now that we have our form ready we want to add it to our product and here is our code. /** * Our custom text * * @uses get_product() Returns the product object for the current product in the loop * @uses get_the_title() Returns the title given the post_id * @uses do_shortcode() Does the shortcode content */ function western_boat_purchase_text(){ $product = get_product(); $product_title = get_the_title( $product->ID ); ?> You can call us at 1-866-644-8111 or fill out the form below.