Skip to content

Get WooCommerce orders by date range

Rutger Kirkels edited this page Feb 13, 2018 · 1 revision

Access to the WooCommerce API is granted by a key and a password.

<?php

use \rutgerkirkels\ShopConnectors\Entities\Credentials\CredentialsFactory;
use \rutgerkirkels\ShopConnectors\Connectors\ConnectorFactory;
use \rutgerkirkels\ShopConnectors\Models\DateRange;

// Build the credentials object
$credentials = CredentialsFactory::build('Woocommerce')
    ->setKey('<your_key>')
    ->setSecret('<your_secret>');

// Build the connector object 
$connector = ConnectorFactory::build(
    'Woocommerce', '<api_host>', $credentials
);

// Determine the date range
$dateRange = new DateRange(new DateTime('2018-01-01'), new DateTime('2018-01-02'));

// Retrieve the orders
$orders = $connector->getOrdersByOrderDate($dateRange);

?>