aligent / bigcommerce-v3-api-php-client

PHP library to interact with the BigCommerce V3 API (https://developer.bigcommerce.com/api-reference#v3-rest-api)
GNU General Public License v3.0
13 stars 23 forks source link

Null returned when there are no orders #161

Closed qadeersahmed closed 1 year ago

qadeersahmed commented 2 years ago

When the combination of Page and Limit is such that the response contains no "Orders" then it crashes giving NULL error. Please fix.

jswift commented 1 year ago

Was really hoping the V2 API for orders would be replaced by now!

$client = new \BigCommerce\ApiV2\V2ApiClient( '...',  '...', '...');

$orders = $client->orders()->getAll();

When there are no orders returned the following error occurs

Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /app/src/BigCommerceLegacyApi/Api/Orders/OrdersApi.php:89
Stack trace:
#0 /app/src/BigCommerceLegacyApi/Api/Orders/OrdersApi.php(89): array_map(Object(Closure), NULL)
#1 /app/test.php(10): BigCommerce\ApiV2\Api\Orders\OrdersApi->getAll()
#2 {main}
  thrown in /app/src/BigCommerceLegacyApi/Api/Orders/OrdersApi.php on line 89
jswift commented 1 year ago

Will be fixed with the next release (1.10.0)