How to Require a Payment Total with a WordPress Form

Have you ever created an order form or donation form, only to have a user accidentally submit a payment of $0? Since the user is unlikely to see the problem when the form is allowed to submit, this could result in confusion and frustration.

In this tutorial, we’ll show you how to require that a form includes an actual payment amount before it can be submitted.

Require the Total for an Order Form

To get started, you’ll need to create a new form or edit an existing form.

For this example, we’ll use the Billing/Order Form template.

new order form

If you want to accept payment, you’ll also want to be sure to install and set up either the PayPal addon or Stripe addon.

By clicking on the Total field in the form builder, you can open its Field Options screen. There, you can check the box for Required.

Require the total field

You can then save this form and, if you haven’t done so already, go ahead and embed it on a page.

If you try to run a test submission with a total of $0, you should see the validation error message, “Payment is required.”

Validation error for a required total field

That’s it! You can now require that the user has a value in the Total field before they can submit the form.

Next, would you like to offer both Stripe and PayPal payment methods? Follow our guide to let users choose their payment method.