Skip to content

Commit

Permalink
Handle orders/carts count errors
Browse files Browse the repository at this point in the history
  • Loading branch information
firstred committed May 2, 2018
1 parent 5a2df4e commit 8c7406f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 9 additions & 2 deletions classes/MailChimpCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,16 @@ public static function getCarts($idShops = null, $offset = 0, $limit = 0, $remai
}
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
} catch (PrestaShopException $e) {
Context::getContext()->controller->errors[] = Translate::getModuleTranslation('mailchimp', 'Unable to count carts properly', 'mailchimp');
if ($count) {
Context::getContext()->controller->errors[] = Translate::getModuleTranslation('mailchimp', 'Unable to count carts properly', 'mailchimp');
} else {
Context::getContext()->controller->errors[] = Translate::getModuleTranslation('mailchimp', 'Unable to find carts', 'mailchimp');
}

return 0;
return false;
}
if (empty($results)) {
return [];
}

$defaultCurrency = Currency::getDefaultCurrency();
Expand Down
6 changes: 5 additions & 1 deletion classes/MailChimpOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ public static function getOrders($idShops = null, $offset = 0, $limit = 0, $rema

$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
} catch (PrestaShopException $e) {
Context::getContext()->controller->errors[] = Translate::getModuleTranslation('mailchimp', 'Unable to count orders', 'mailchimp');
if ($count) {
Context::getContext()->controller->errors[] = Translate::getModuleTranslation('mailchimp', 'Unable to count orders', 'mailchimp');
} else {
Context::getContext()->controller->errors[] = Translate::getModuleTranslation('mailchimp', 'Unable to find orders', 'mailchimp');
}

return false;
}
Expand Down

0 comments on commit 8c7406f

Please sign in to comment.