0

I wrote a program that automatically fullfills my orders from woocommerce. After having fullfilled the order I changed the order_status from the order to "wc-completed" via sql.

Everything works fine but the email which should be send when an order is completed is not send. Do you have any ideas how I can solve this problem?

Thank you very much for your answers, Philipp

1 Answer 1

0

If you make the changes directly through SQL you won't trigger the order change event and that's why the email is not being sent.

Instead of changing order via SQL you need to use some predefined function like update_status :

$ord = new WC_Order($ID); //ID of the order
$ord->update_status('completed')
2
  • Hey, that makes sense, thank you! To be honest, I am new in coding with php. I wanted to create a php file which turn the order_status of a special order (for example 108) to 'completed'. As I opened the page there was always an error like: class WC_Order not found. How can I use the predefined functions from Woocommerce in external php file? Greetings, Philipp Dec 26, 2017 at 1:49
  • @PhilippRitter in order to use such function you need to include the necessary files .... but i think it's gonna be a bit difficult to do from an external file. As you need to include both Woocommerce files and WP files which means you need to be on the site Dec 26, 2017 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.