Holding form notification until a successful WooCommerce purchase

I’ve a form that leads to WooCommerce carts with specific products based on conditional logic.
Currently, in the last step the user needs to fill a form with personal details (registration to our group) and then gets redirected to the desired cart pays and the flow is done.

But I noticed that some people don’t buy the product and I still get the email notification with the personal details so I need to go and check if the user successfully paid or not.

Is there any way to hold the notification email until a successful purchase occurs?

I dived into the hooks of GF and WooCommerce and I found the “woocommerce_payment_complete” hook but I’m not sure how to integrate it with GF hooks.


Hi Dan. I’m not a Woocommerce expert by any means, but by default, Woocommerce disables the Gravity Forms notifications, and sends its own notifications. If you have other notifications configured for the form, it is possible that those are not being disabled by Woocommerce.

I recommend testing the form with Gravity Forms logging enabled, to see what notifications are being sent by Gravity Forms. In order to help troubleshoot the issue you’re having, we need to see what’s going on behind the scenes with Gravity Forms, which means we need Gravity Forms logging enabled. You can enable logging by going to Forms > Settings > Logging. Select: On, then [Save Settings]. By default this will enable all logging on your site. Documentation for Enabling Logging: https://docs.gravityforms.com/logging-and-debugging/#enabling-logging

After enabling logging, please test the form and refer back to the log to see if any notifications were disabled by Woocommerce, and what notifications were sent.

Thank you Chris!
I probably didn’t explain myself well.
I don’t have any integration of Woocommerce and Gravity Forms.

Maybe this drawing will explain it better:

I hope it’s more clear now.
Thank you again!

Based on your description, you would need to link the “Notification Event” to something that is based on something happening in Woocommerce. If there is an event listed in the Notifications Event dropdown, you can change it there. We describe the notification events here: https://docs.gravityforms.com/gform_notification_events/

However, if there is no notification event for a Woocommerce action, you could either trigger the notification with a Woocommerce hook (I’m not sure which Woocommerce hook it would be, but you can send the notification like this) OR you could create a custom notification even for a Woocommerce action, so that you have something like “Woocommerce purchase” as the notification event, and that send the notification with the API function.

Let us know what you find out.

I’m not sure why but I don’t have the Event dropdown at all.

I think your first idea should be easier for me because I found the Woocommerce hook that triggers after a successful payment.
That leads me to ask how GF remembers the the data that the user filled in the form? the user already left the form…

You won’t necessarily have a Notification Event dropdown. That normally appears when you have a payment add-on installed, or are using save and continue functionality. Certain add-ons will add their own events.

Once the form is submitted, the data is stored in the database and accessible via the $entry. What is the Woocommerce hook to trigger a notification?

I guess I don’t have any payment add-ons…

The Woocommerce hook is woocommerce_payment_complete
According to what I found, it is called after the payment has been taken for an order.
So I thought I can use it to trigger the notification after the payment.

That’s good that you found an appropriate hook. Use the documentation for that, and combine that hook with the examples shown here to send a notification for a form using the API function:

I want to test it but not on a production website.
Is there any way to activate GF on another WP installation just to play with it?

Hi Dan. The best way to experiment is with a free Gravity Forms demo site:

For the email notifications to work, please see the note when you sign up, or at the top of the WordPress dashboard when you are logged in. You will need to set that up before experimenting with any code. Thank you.

Hi Chris,
I managed to get it working partially.

  1. I get a blank email when sending the notification.
    When using var_dump I can see the correct entry and all the fields but the email is still blank.

  2. I get 2 emails, first one when form is submitted and the second when the hook is triggered.
    I need to disable the first one but not sure how.

Any help would be appreciated.

Hi Dan. I recommend opening a support ticket and putting in there “Attn Chris” so I can dig in further.

Thank you.

I wonder if this worked out in the end. I’m trying to figure out how to set up something similar, though I’m nowhere near as experienced or confident with GF as Dan sounds.

In essence, I too would like to set up a form that completes only if the user also makes a WooCommerce Product purchase. I’ve been unsuccessfully looking for a way to connect GF and WC but most of what I find online presumes I want to add a form to a product rather than, as I do, a product to a form, as it were.

What Dan describes in his first question here is very close to what I want to do. I only wish there was more info for a newcomer like myself.

Hi PeeGeeBee,

Have you seen the Gravity Flow WooCommerce extension? Being able to have the payment, checkout or other WC activities triggered as steps within a workflow following form submission can make for a seamless user experience. Dan’s original Q about having the notification trigger after payment would be quite possible without requiring custom code with it.

There is a lot to WC, and this extension as a result. We’ve documented each of the step types the extension provides, and are more than happy to help if you need it getting started via our support.