Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSquareItems not filtering types #13

Closed
BarnumD opened this issue Jul 2, 2020 · 1 comment
Closed

getSquareItems not filtering types #13

BarnumD opened this issue Jul 2, 2020 · 1 comment

Comments

@BarnumD
Copy link

BarnumD commented Jul 2, 2020

In the following example, listCatalog is not filtering by types, such as ITEM.'

function getSquareCatalog($types = 'ITEM'){
  $client = getApiClient();
  $catalogApi = $client->getCatalogApi();
  $cursor = 'initial';
  $catalog = array();

  while ($cursor){
    if ($cursor == 'initial'){$cursor = null;}
    $apiResponse = $catalogApi->listCatalog($cursor, $types);

    if ($apiResponse->isSuccess()) {
      $listCatalogResponse = $apiResponse->getResult();
      $catalog= array_merge ($catalog, $listCatalogResponse->getObjects());

      $cursor = $listCatalogResponse->getCursor();
    }
  }
  return $catalog;
}

print("<pre>".print_r(getSquareCatalog(),true)."</pre>");

Returns all item types including ITEM, CATEGORY, TAX, DISCOUNT

@BarnumD
Copy link
Author

BarnumD commented Jul 2, 2020

User issue, failed to realize I was calling getSquareCatalog() with null argument.

@BarnumD BarnumD closed this as completed Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant