Editor’s note: This article is about creating WooCommerce products using the Advanced Post Creation Add-on. If you’re looking for a native Gravity Forms & WooCommerce integration, check out Gravity Shop Product Configurator, which lets you embed Gravity Forms inside WooCommerce products.
Did you know that the Gravity Forms Advanced Post Creation Add-On can create WooCommerce Products? It opens up a whole world of possibilities where users can create products completely on the front end.
For example, you can create your own marketplace specific to vendors in your niche, like a focused version of Etsy. Those vendors can add new products using your form.
In this tutorial, our niche is stickers, and the form we’re going to build lets users add their own stickers for sale on our site, but we’ve seen this on sites that sell music, art prints, stock photos, and more.
- Getting Started
- WooCommerce Products
- Creating Products with Gravity Forms
- Taking it Further
In this tutorial, we’re going to do a deep dive on building a form that will create a WooCommerce Product on submission.
WooCommerce stores a lot of data for each product, and before we can build a form that will create them, we need to first get an understanding of what kind of values we must pass to create a product and how those values are stored in the WordPress database.
The following fields are what I would consider the minimum to create a WooCommerce Product that can be sold in your store. Technically they aren’t all required, but from my experience excluding any of them will exclude sales.
- Name – The name of your Product, which also used for the Product slug.
- Description – The description displays on the Product page.
- Price – WooCommerce allows for two prices: regular price and sale price.
- Featured Image – The featured image is used extensively in a WooCommerce store. All products should have one.
These next fields are optional, but are commonly used with WC Products.
- Category – Similar to WordPress Post categories, this is the taxonomy for the Product.
- Tags – SEO tags to increase Product visibility in searches.
- SKU – If you track inventory, unique Stock Keeping Units are attached to all Products. It’s located under the Inventory tab.
- Weight – Product weight is used to determine shipping costs. Find it in the Shipping tab.
- Product Gallery – On top of the Featured Image, Products can contain galleries that are displayed on the Product page.
Creating Products with Gravity Forms
With a solid understanding of WooCommerce Products, we’re ready to build a form that will create new Products. Let’s get started.
Step 1 – Add Your Fields
We’re going to add all of the fields from above to our form because I like building ambitious forms. Here’s a breakdown of how I have set up my form:
- For Product Name, Regular Price, Weight, and SKU we’ll add a Single Line Text field.
- Add a Paragraph field for the Product Description so the user has a little more room.
- Featured Image and Gallery require File Upload fields.
- Just like other WordPress Posts, WooCommerce Products support multiple categories, so I recommend a Checkbox field for adding categories to your Product.
Below is the entire form with all the fields added.
GF File Upload Pro
Step 2 – Create APC Feed
With the fields in place, it’s time to create an Advanced Post Creation feed and map the fields to the WooCommerce fields.
Give your Feed a Name and set the Post Type to Product.
Under Post Content, we’ll map most of our fields. The APC Add-On automatically supports standard Post fields, but WooCommerce has some custom fields that need to be mapped manually. We’ll start with the supported fields.
Title, Content, and Featured Image are simple to map. Simply select the merge tag for Title and Content that matches your Name and Product Description fields. For Featured Image, select your appropriately named File Upload field.
For Gallery, Price, Weight, and SKU, we’ll need to manually map the fields. To do this, select Add New Custom Field Name at the bottom of the Select Custom Field Name Drop Down. Then, type in each of the appropriate field types. Note the leading underscore; this is required.
_priceto have a value. If you omit either one, the price won’t appear on the Product page.
Here’s a reference for easy copy/pasting of the field names:
_product_image_gallery _regular_price _price _weight _sku
Under Taxonomies you can map the Categories field. You can also map to any additional taxonomies, such as Tags or custom WC Taxonomies.
With those two steps completed, you’re all set to create WooCommerce Products with your form. Give it a spin and you’ll be generating Products in no time.
Taking it Further
Automatically Populate Categories and Tags
Use GF Populate Anything to automatically populate Categories and Tags into Checkbox fields. Populate Taxonomy Term and set the Filter and Choice Template according to this screenshot.
Uploading to the WooCommerce Product Gallery
Use GF Media Library to upload images to the WooCommerce Image Gallery. Simply check the Upload to Media Library option and map the field as shown in Step 2.
Enhance File Upload Fields
Use GF File Upload Pro to add image previews, cropping, maximum file size limits, real-time upload validation, and more to Multi-File Upload fields.
Gravity Forms QR Code can help you bridge the physical and digital world. Generate QR codes from Gravity Forms field values, or scan QR codes to insert values into Gravity Forms fields. Learn more about Gravity Forms QR Code.