2

I have an eCommerce site running Woocommerce on top of Wordpress, and the company running it has changed there shipping system to an external company who stores the products in their warehouse and ships the products when they are bought.

In terms of automation, downloading information on new orders and sending it to the shipping company is fine, but when they respond to me with an XML of the orders sent and the associated tracking numbers, I need to be able to have a system that automatically updates the orders (including sending out the emails necessary). However, the only way I currently know how to do that is to update the MySQL database. But with that method, the automated email system is overridden and ignored.

Does anyone know how I can update orders statues and other information programmatically, which would allow Woocommerce's internal functions to be executed in the same way as manually logging into the admin side and updating the order?

topherg
  • 4,203
  • 4
  • 37
  • 72

1 Answers1

4

Found a solution to this yet?

The code below works to mark an order as complete, but does not execute other actions as you describe in the admin

// create a new checkout instance and order id
$checkout = new WC_Checkout();
$this_order_id = $checkout->create_order();

$order = new WC_Order($this_order_id);
$order->update_status('completed');
Dennis
  • 51
  • 5
  • That's a nice solution, i'll have to try that out. The ultra high tech solution we went with was to hire a someone to go through the admin, and create the modifications manually. But, this was almost a year ago, and my understanding of WooCommerce has improved considerably, so maybe another go is in order (no pun, promise). I'll let you know if it works. I might be able to augment that with some extra meta fields that I have gleaned from the database and from the WooCommerce source – topherg Jan 15 '14 at 10:56
  • Nice! Order complete is working, working on the rest ... http://stackoverflow.com/questions/21126885/on-woocommerce-order-complete-activate-woosensei-course – Dennis Jan 15 '14 at 13:27
  • adding extra metafields with: update_post_meta( $this_order_id, $key, $value); – Dennis Jan 15 '14 at 13:31
  • nice one, that's really helpful :) – topherg Jan 15 '14 at 14:51