Advanced Integrations with Premium Form Plugins Tutorial
Sprout Invoices already integrates with the most popular WordPress form plugins in a couple different ways through add-ons:
- Advanced Form Integrations: Ninja Forms, Formidable, & GravityForms: Use your premium plugin based form to accept estimate requests that integrate with Sprout Invoices.
- Dynamic Invoice Submissions from GravityForms, Ninja Forms, & Formidable: Pre-defined Line Items are used for the user to select what s/he wants to purchase.
In the example below I'll review how to use a gravity form with conditional logic to create an invoice, client, and user after submission.
Here's the form in action without the integration...
Here's the form with the customization that will be reviewed below...
Step-by-Step Customization
Remove the payment option from your existing GF form
If your form has the Credit Card you will need to remove it, since you're redirecting your customers/clients to a newly created invoice for them to review and pay.
Hook into the form submission
The different form plugins have different ways to hook into the submitted form, for Ninja Forms it's ninja_forms_post_process
, for Formidable it's frm_after_create_entry
, and for Gravity Forms it's gform_entry_created
. Again this example will use Gravity Forms.
Here's a code snippet with a lot of comments for you to review, customize, and implement.
Hook into the form confirmation
Hooking into the confirmation is necessary if you want to redirect the submitter directly to their invoice for payment. Here's some example code for the same Gravity Form above.
The only thing you need to change with this is the id at the end of the hook, i.e. gform_confirmation_ 5.
That's it!
As you'll notice, hopefully if you made it this far, is that you just need to handle how you want to create line items.