Search code examples
phpcurlwoocommercephp-curlwoocommerce-rest-api

PHP Curl additional parameters for Woocommerce API


I'm able to collect all orders using the default curl request:

curl https://example.com/wp-json/wc/v3/orders -u consumer_key:consumer_secret

But what I want to add a couple parameters and unsure how. I have tried adding it to the url, but with no luck:

curl https://example.com/wp-json/wc/v3/orders?status=completed&after=2023-06-01T00:00:00-00:00 -u consumer_key:consumer_secret

I did try using -d '{"status":"completed"}', but this seemed to create an order (even though I have not stipulated -X POST or PUT

Any help would be greatly appreciated. Thanks


Solution

  • You'll need to wrap the URL inside quotes. Execute the curl command like this:

    curl "https://example.com/wp-json/wc/v3/orders?status=completed&after=2023-06-01T00:00:00-00:00" -u consumer_key:consumer_secret