How To Automatically Set WooCommerce PayPal Orders as Completed

October 22nd, 2013 - Posted by Steve Marks to MySQL, PHP, Software, Web Development.

In a normal E-commerce operation an order will be made, the customer will pay for it, the order will be fulfilled and the item(s) dispatched, at which point the order will probably be marked as ‘Completed’.

This process is supported in WooCommerce and allows the order to go from ‘Pending’, to ‘Processing’, and finally to ‘Completed’ once the products have been sent out.

This is fine for orders where a physical item exists, but what about virtual orders? There is no notion of postage or sending out items. This is exactly the scenario I had in my latest E-commerce project where the customer had only virtual products on offer.

In this case, when someone paid via PayPal we needed to set the order straight to ‘Completed’ once payment had been received, instead of having to manually log into WordPress and update the order status ourselves.

The steps below explain how I achieved this, as well as how I overcame some problems along the way where I got stuck:

Note: The below assumes that you already have WordPress and WooCommerce in place, and that you have PayPal set up as a payment method.

1. Download the ‘WooCommerce Autocomplete Order’ plugin

First of all, you’ll need to download and activate the ‘WooCommerce Autocomplete Order’ plugin.

Now, at first this plugin sounds like it could be perfect. Unfortunately however the documentation is quite frankly non-existent, especially in the PayPal scenario where a few extra steps are required to get this up and running.

2. Set your products as ‘Virtual’

The above plugin only works for orders containing virtual products so make sure you’ve ticked the ‘Virtual’ box on your products.

Woocommerce Virtual Product

3. Activate PayPal IPN

Instant Payment Notification (also know as IPN) is a message service that automatically notifies merchants (in our case WooCommerce) of events related to PayPal transactions. It’s this bit that was missing in my scenario, and the missing piece of the puzzle.

To setup IPN you need to login to PayPal itself, navigate to ‘Profile > My Selling Tools > Instant payment notifications’ and update the information as follows:

PayPal IPN Settings
Simply enter the URL in the format ‘http://your-domain/?wc-api=WC_Gateway_Paypal‘, enable IPN messages and click ‘Save’.

4. Ensure the ‘Receiver Email’ is correct

The last remaining step is to ensure the ‘Receiver Email’ setting in WooCommerce under the ‘PayPal’ section is set correctly. Normally I believe you should be able to leave this blank, however if you’ve changed it for testing or debugging purposes, it might be worth just making sure that this is correct.

5. Test

And that’s really it. The final step is to simply carry out an order and hopefully, as soon as the payment has been made via PayPal, the order will automatically be set to ‘Completed’ in the WooCommerce backend. No more having to login and set it manually.

This entry was posted on Tuesday, October 22nd, 2013 at 7:44 pm by +Steve Marks and is filed under MySQL, PHP, Software, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.

Fear not, we won't publish this

Comments (4)
  1. Ouch! Sounds painful :) Glad it helped!

  2. Chris says:

    Thank you so much for this, I was literally smashing my head against the wall wondering why the order is not completed automatically.

  3. We had no idea that virtual products needed downloadable checked as well to have the final email be sent to the customer!

    Thanks for the post.

  4. Thank you, was racking my brain and this explanation saved me!