pixelpeter / laravel5-woocommerce-api-client

Laravel 5 wrapper for the Woocommerce REST API
MIT License
125 stars 48 forks source link

Filter parameter doesn't appear to do anything #14

Closed Voidmine closed 7 years ago

Voidmine commented 7 years ago

The order filter in the example code doesn't appear to be functioning correctly.

$data = [
    'status' => 'completed',
    'filter' => [
        'created_at_min' => '2016-01-14'
    ]
];
$result = Woocommerce::get('orders', $data);

If I run the above code then I get the default 10 results without any filtering (it returns orders from before that date). Similarly, if I add a per_page parameter of 100, then it will return 100.

I initially discovered this while trying to figure out how to only show variable products so I could try to figure out how to list their variations (trying to get a master list of products with SKUs - like you can do in a WP query by searching for posts with type 'product' and 'product_variation'). Not sure on the best way to do it via the API.

$data = [
        'per_page' => 100, //max 100
        'page' => $current_page,
        'filter' => [
            'type' => 'variable'
            ]
    ];
    $result = Woocommerce::get('products', $data);

PS - looking forward to your planned addition of the get response header functions so we can use paginated results without hardcoding loop values. Thanks for the hard work!

pixelpeter commented 7 years ago

This repository is just a wrapper around the php woocommerce rest api for easier integration into Laravel. That's why you can (normally) apply the same syntax as documented here: http://woocommerce.github.io/woocommerce-rest-api-docs

After some research I unfortunately found this: https://github.com/woocommerce/woocommerce/issues/11996#issuecomment-269487111

Looks like filterwill be removed :-(

Just found out that it also stopped working for me ... ... will have a deeper look into it

pixelpeter commented 7 years ago

I found the solution in the docs: https://woocommerce.github.io/woocommerce-rest-api-docs/#index

        $params = [
                'after' => '2017-01-24T00:00:00'
        ];
        return Woocommerce::get('orders', $params);