Do you want your visitors to be able to choose to donate to your nonprofit as they’re filling out a form? Using conditional logic, you can hide fields unless the user chooses a certain option. In this article, we’ll walk you through how to add optional payment to your WordPress form.
Adding Form Fields
Also, you’ll need to have a form created. See our tutorial on How to Create a Simple Contact Form as an example to get started. You can use any kind of form, but for this tutorial we’ll be using a contact form.
The default contact form comes with Name, Email, and Comment or Message fields. We need to add the Multiple Choice, Credit Card, and Single Item fields to the form.
Customizing Form Fields
The Multiple Choice field comes with three choices but you only need two choices for optional payment. You can simply remove the third choice by clicking on the field in the right panel to edit and then deleting the third choice in the left panel.
Since you’ll going to be asking your visitors if they would like to donate, it’ll be a good idea to change the labels for the multiple choice. You can do so by simply clicking on the multiple choice field in the right panel to edit and changing the labels in the left panel.
The Single Item field needs to be set to User Defined so users can enter in their own donation amount. You can do this by configuring the advanced settings for the Single Item field.
If you need help customizing the donation amounts, you can read this article on how to create a donation form with multiple amounts.
Enabling Conditional Logic
To add optional payment to your form you first need to enable conditional logic on the payment field.
You can enable it by clicking the field, then expanding the Conditionals section. From there, click the Enable Conditional Logic checkbox.
Next, you’ll want to set up the logic so that the credit card field only shows when the user selects Yes, I’d like to donate.
So if someone doesn’t want to donate, the Stripe field won’t show up.
Now we need to tell Stripe not to try to process the payment if the visitor doesn’t want to donate.
To do that, click the Payments icon on the left of the form builder. Let’s use Stripe in this example.
Click on Stripe, then go ahead and click the Enable conditional logic checkbox in the right hand pane. Underneath, create a rule that says Don’t process if the user selects No, thanks.
Now, even if the user types a value into the donation field, the form won’t charge their card if they’ve selected No, thanks.
After you are done configuring the order form settings, click Save to store your changes and your form is ready to be published on your site.
That’s it! You’ve just added optional payment to your WordPress form.
Want to accept payment for the online orders? Check out how to process payments with your WordPress order forms.
If you’re looking to save even more time processing online orders, you can check out our tutorial on how to create a client booking form that connects with your calendar software.
What are you waiting for? Get started with the most powerful WordPress forms plugin today.