Create an order in woocommerce from a multiple step gravity form

Hello Gravity Community

I trust you are all keeping well.

I was doing some research and found this topic very interesting: Gravity Form to create order in woocommerce

I have a situation where we want to create a form page with multiple steps and input/selection fields that hold values (underlying); we need to then create an order on WooCommerce when the user clicks the submit button.

Has anyone ever tried the above or found another solution to this possibly?

The advice or direction is greatly appreicated.

Kindest Regards,
Oliver

The other post is nice, but it’s better to go with the source WooCommerce API - Create an Order. Depending on how complex the order, you indicate there are multiple steps and inputs, I usually create a test order and retrieve it via WooCommerce API using Postman so I have an exact example of the formatted JSON.

Use gform_after_submission, obtain variables from the form input, map them accordingly, create a JSON string, and submit it to your API endpoint using CURL. This PHP code can be placed in the themes functions file, a simple standalone plugin, or the Code Snippets plugin.

1 Like

@tugmariner is spot on that the use of the WC API is best route to go.

You mention having multiple steps and input selections to be submitted before being ready to create the order. Gravity Flow, and its’ user input step type, might be one you want to look at how it could help your use case.

For the API call, a no code approach with the outgoing webhook step type should be very easy. Not only does it make the field mapping as easy as the Gravity Forms webhooks add-on, but through it you can also map response values from the API back. And there are filters such as gravityflow_webhook_args if you do need a little snippet of code to adjust field values or other request args.

Our WooCommerce extension also covers a few other use cases that may be of interest beyond the initial order creation?

Cheers,
Jamie

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.