I'm looking for a way o create my own web interface to view and manage WordPress/WooCommerce orders.
The idea is that I do not want to use the WP backend, this is for a small takeaway shop that wants to simply be able to view just the orders and accept them and then press a button to mark orders as complete.
I have ha da quick look into it and it seems that WooCommerce provides an API to hook into. I would prefer to build this using PHP and have found this https://packagist.org/packages/woothemes/woocommerce-api
This supposedly allows me to interact with the woocommerce using PHP I'm just not 100 sure where to start. I guess my question is:
Is this actually possible? It should simply display the orders on a webpage as they come in (some form of auto refresh) and allow me to mark orders as complete or not.
and How would I start this?
Any help would be appreciated.
Edit: Ok so after having a quick crack at this I have actually got an example page up and running, connected to my WooCommerce site and it displays the orders.
I now need to figure out how to only show the relevant information as this is an example of want it prints out right now
stdClass Object ( [orders] => Array ( [0] => stdClass Object ( [id] => 16 [order_number] => 16 [created_at] => 2015-07-29T17:24:00Z [updated_at] => 2015-07-29T17:24:00Z [completed_at] => 2015-07-29T16:24:00Z [status] => processing [currency] => GBP [total] => 0.00 [subtotal] => 0.00 [total_line_items_quantity] => 1 [total_tax] => 0.00 [total_shipping] => 0.00 [cart_tax] => 0.00 [shipping_tax] => 0.00 [total_discount] => 0.00 [shipping_methods] => [payment_details] => stdClass Object ( [method_id] => [method_title] => [paid] => 1 ) [billing_address] => stdClass Object ( [first_name] => Chris [last_name] => Last name [company] => [address_1] => number [address_2] => [city] => town [state] => [postcode] => post code [country] => GB [email] => email [phone] => phone # ) [shipping_address] => stdClass Object ( [first_name] =
Any idea how I can extract on the relevant information. To get this data I used:
print_r( $client->orders->get() );
Apologies for the ignorance I am new to this JSON stuff :)
Ok so edit number 3 here:
As before I can view orders by using this:
print_r( $client->orders->get() );
So I thought maybe I could use a foreach loop to iterate through the array. But this doesn't seem to work.
$orders = $client->orders->get();
foreach ($orders as $key => $value){
echo $key . '=' . $value . '</br>';
}
Any ideas?
Ok so update number 4!
This loop seems to work(ish)
foreach( $orders as $order ) {
foreach( $order as $value ) {
echo $value["id"] . '</br>';
echo $value["status"] . '</br>';
echo $value["total"] . '</br>';
}
}