Skip to content

Commit

Permalink
Update the ‘list all orders’ example in README.md to match new syntax…
Browse files Browse the repository at this point in the history
… for API v1
  • Loading branch information
pixelpeter committed Jan 25, 2017
1 parent 76abf07 commit 3f23f80
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ return Woocommerce::get('orders');
```

### View all completed orders created after a specific date
#### For legacy API versions
(WC 2.4.x or later, WP 4.1 or later) use this syntax

```php
use Woocommerce;

Expand All @@ -105,7 +108,35 @@ foreach($orders as $order)
{
// do something with $order
}
```

#### For current API versions
(WC 2.6.x or later, WP 4.4 or later) use this syntax.
`after` needs to be a ISO-8601 compliant date!≠

```php
use Woocommerce;

$data = [
'status' => 'completed',
'after' => '2016-01-14T00:00:00'
]
];

$result = Woocommerce::get('orders', $data);

foreach($result['orders'] as $order)
{
// do something with $order
}

// you can also use array access
$orders = Woocommerce::get('orders', $data)['orders'];

foreach($orders as $order)
{
// do something with $order
}
```

### Update a product
Expand Down

0 comments on commit 3f23f80

Please sign in to comment.