{"id":27919372,"url":"https://github.com/pixelpeter/laravel5-woocommerce-api-client","last_synced_at":"2025-05-15T18:07:44.937Z","repository":{"id":52421066,"uuid":"50013954","full_name":"pixelpeter/laravel5-woocommerce-api-client","owner":"pixelpeter","description":"Laravel 5 wrapper for the Woocommerce REST API","archived":false,"fork":false,"pushed_at":"2025-04-15T04:26:31.000Z","size":60,"stargazers_count":124,"open_issues_count":9,"forks_count":48,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-06T19:17:08.330Z","etag":null,"topics":["laravel","rest","woocommerce","wordpress"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pixelpeter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-20T07:51:50.000Z","updated_at":"2025-04-27T23:55:18.000Z","dependencies_parsed_at":"2022-09-16T15:11:35.713Z","dependency_job_id":null,"html_url":"https://github.com/pixelpeter/laravel5-woocommerce-api-client","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelpeter%2Flaravel5-woocommerce-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelpeter%2Flaravel5-woocommerce-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelpeter%2Flaravel5-woocommerce-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixelpeter%2Flaravel5-woocommerce-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixelpeter","download_url":"https://codeload.github.com/pixelpeter/laravel5-woocommerce-api-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252752078,"owners_count":21798724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","rest","woocommerce","wordpress"],"created_at":"2025-05-06T19:17:20.101Z","updated_at":"2025-05-06T19:17:20.820Z","avatar_url":"https://github.com/pixelpeter.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel 5 WooCommerce API Client\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/pixelpeter/laravel5-woocommerce-api-client.svg?style=flat-square)](https://packagist.org/packages/pixelpeter/laravel5-woocommerce-api-client)\n[![Total Downloads](https://img.shields.io/packagist/dt/pixelpeter/laravel5-woocommerce-api-client.svg?style=flat-square)](https://packagist.org/packages/pixelpeter/laravel5-woocommerce-api-client)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Coverage Status](https://coveralls.io/repos/github/pixelpeter/laravel5-woocommerce-api-client/badge.svg?branch=master)](https://coveralls.io/github/pixelpeter/laravel5-woocommerce-api-client?branch=master)\n[![Tests](https://github.com/pixelpeter/laravel5-woocommerce-api-client/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/pixelpeter/laravel5-woocommerce-api-client/actions/workflows/run-tests.yml)\n[![Fix PHP code style issues](https://github.com/pixelpeter/laravel5-woocommerce-api-client/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/pixelpeter/laravel5-woocommerce-api-client/actions/workflows/fix-php-code-style-issues.yml)\n[![PHPStan](https://github.com/pixelpeter/laravel5-woocommerce-api-client/actions/workflows/phpstan.yml/badge.svg)](https://github.com/pixelpeter/laravel5-woocommerce-api-client/actions/workflows/phpstan.yml)\n[![dependabot-auto-merge](https://github.com/pixelpeter/laravel5-woocommerce-api-client/actions/workflows/dependabot-auto-merge.yml/badge.svg)](https://github.com/pixelpeter/laravel5-woocommerce-api-client/actions/workflows/dependabot-auto-merge.yml)\n\nA simple Laravel 5 wrapper for the [official WooCommerce REST API PHP Library](https://github.com/woothemes/wc-api-php) from Automattic.\n\n## Version overview\n\n| Laravel | wc-api-php used | Wordpress |  Woocommerce  |          WC API version           | use branch |\n| ------  | --------------- | --------- | ------------- | --------------------------------- |------------|  \n| 5.7+    | 2.x             | 4.4+      | 3.5+          | v1, v2, v3                        | master     |\n| 5.5+    | 1.3.x           | 4.4+      | 3.0 - 3.4.x   | v1, v2, v3                        | ^3.0       |\n| 5.4+    | 1.3.x           | 4.4+      | 2.6 - 2.6.14  | v1, v2                            | ^2.0       |\n| 5.3     | 1.3.x           | 4.1+      | 2.1 - 2.5.5   | legacy v1, legacy v2, legacy v3   | ^1.0       |\n\n## Installation\n\n### Step 1: Install Through Composer\n\nFor API Version v2, WooCommerce 3.0+, Wordpress 4.4+, php 7.0+, Laravel 5.5+ use the v3.x branch\n``` bash\ncomposer require pixelpeter/laravel5-woocommerce-api-client ^3.0\n```\n\nFor API Version v1, WooCommerce 2.6+, Wordpress 4.4+, Laravel 5.4+ use the v2.x branch\n``` bash\ncomposer require pixelpeter/laravel5-woocommerce-api-client ^2.0\n```\n\nFor older versions of Woocommerce starting from 2.1+ use the v1.x branch\n``` bash\ncomposer require pixelpeter/laravel5-woocommerce-api-client ^1.0\n```\n\n### Step 2: Add the Service Provider (not needed with v3.x)\nAdd the service provider in `app/config/app.php`\n```php\n'provider' =\u003e [\n    ...\n    Pixelpeter\\Woocommerce\\WoocommerceServiceProvider::class,\n    ...\n];\n```\n\n### Step 3: Add the Facade (not needed with v3.x)\nAdd the alias in `app/config/app.php`\n```php\n'aliases' =\u003e [\n    ...\n    'Woocommerce' =\u003e Pixelpeter\\Woocommerce\\Facades\\Woocommerce::class,\n    ...\n];\n```\n\n### Step 4: Publish configuration\n``` bash\nphp artisan vendor:publish --provider=\"Pixelpeter\\Woocommerce\\WoocommerceServiceProvider\"\n```\n\n### Step 5: Customize configuration\nYou can directly edit the configuration in `config/woocommerce.php` or copy these values to your `.env` file.\n```php\nWOOCOMMERCE_STORE_URL=http://example.org\nWOOCOMMERCE_CONSUMER_KEY=ck_your-consumer-key\nWOOCOMMERCE_CONSUMER_SECRET=cs_your-consumer-secret\nWOOCOMMERCE_VERIFY_SSL=false\nWOOCOMMERCE_VERSION=v1\nWOOCOMMERCE_WP_API=true\nWOOCOMMERCE_WP_QUERY_STRING_AUTH=false\nWOOCOMMERCE_WP_TIMEOUT=15\n```\n\n## Examples\n\n### Get the index of all available endpoints\n```php\nuse Woocommerce;\n\nreturn Woocommerce::get('');\n```\n\n### View all orders\n```php\nuse Woocommerce;\n\nreturn Woocommerce::get('orders');\n```\n\n### View all completed orders created after a specific date\n#### For legacy API versions \n(WC 2.4.x or later, WP 4.1 or later) use this syntax\n\n```php\nuse Woocommerce;\n\n$data = [\n    'status' =\u003e 'completed',\n    'filter' =\u003e [\n        'created_at_min' =\u003e '2016-01-14'\n    ]\n];\n\n$result = Woocommerce::get('orders', $data);\n\nforeach($result['orders'] as $order)\n{\n    // do something with $order\n}\n\n// you can also use array access\n$orders = Woocommerce::get('orders', $data)['orders'];\n\nforeach($orders as $order)\n{\n    // do something with $order\n}\n```\n\n#### For current API versions \n(WC 2.6.x or later, WP 4.4 or later) use this syntax.\n`after` needs to be a ISO-8601 compliant date!≠\n\n```php\nuse Woocommerce;\n\n$data = [\n    'status' =\u003e 'completed',\n    'after' =\u003e '2016-01-14T00:00:00'\n    ]\n];\n\n$result = Woocommerce::get('orders', $data);\n\nforeach($result['orders'] as $order)\n{\n    // do something with $order\n}\n\n// you can also use array access\n$orders = Woocommerce::get('orders', $data)['orders'];\n\nforeach($orders as $order)\n{\n    // do something with $order\n}\n```\n\n### Update a product\n```php\nuse Woocommerce;\n\n$data = [\n    'product' =\u003e [\n        'title' =\u003e 'Updated title'\n    ]\n];\n\nreturn Woocommerce::put('products/1', $data);\n```\n\n### Pagination\nSo you don't have to mess around with the request and response header and the calculations this wrapper will do all the heavy lifting for you.\n(WC 2.6.x or later, WP 4.4 or later) \n\n```php\nuse Woocommerce;\n\n// assuming we have 474 orders in pur result\n// we will request page 5 with 25 results per page\n$params = [\n    'per_page' =\u003e 25,\n    'page' =\u003e 5\n];\n\nWoocommerce::get('orders', $params);\n\nWoocommerce::totalResults(); // 474\nWoocommerce::firstPage(); // 1\nWoocommerce::lastPage(); // 19\nWoocommerce::currentPage(); // 5 \nWoocommerce::totalPages(); // 19\nWoocommerce::previousPage(); // 4\nWoocommerce::nextPage(); // 6\nWoocommerce::hasPreviousPage(); // true \nWoocommerce::hasNextPage(); // true\nWoocommerce::hasNotPreviousPage(); // false \nWoocommerce::hasNotNextPage(); // false\n```\n\nIn some cases the web server returns headers only in lower case. This may cause errors when\nusing the pagination functions. If that is your case, call the following method before calling \nany pagination methods.\n\n```php\nuse Woocommerce;\n\nWoocommerce::useLowerCaseHeaders();\n```\n\n### HTTP Request \u0026 Response (Headers)\n\n```php\nuse Woocommerce;\n\n// first send a request\nWoocommerce::get('orders');\n\n// get the request\nWoocommerce::getRequest();\n\n// get the response headers\nWoocommerce::getResponse();\n\n// get the total number of results\nWoocommerce::getResponse()-\u003egetHeaders()['X-WP-Total']\n```\n\n### More Examples\nRefer to [WooCommerce REST API Documentation](https://woocommerce.github.io/woocommerce-rest-api-docs) for more examples and documention.\n\n## Testing\nRun the tests with:\n```bash\nvendor/bin/phpunit\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelpeter%2Flaravel5-woocommerce-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixelpeter%2Flaravel5-woocommerce-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelpeter%2Flaravel5-woocommerce-api-client/lists"}