Skip to content

Commit

Permalink
Catch email fetching errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dukeimg committed Aug 1, 2018
1 parent 242ab80 commit c65989b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
36 changes: 26 additions & 10 deletions Helper/OrderData.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,35 @@ public function getEmail($order)
{
if ($this->is_empty($order))
return '';

if (!($this->is_empty($order->getCustomerEmail())))
return $order->getCustomerEmail();

else if (!($this->is_empty($order->getShippingAddress()->getEmail())))
return $order->getShippingAddress()->getEmail();
try {
if (!($this->is_empty($order->getCustomerEmail())))
return $order->getCustomerEmail();
} catch(\Exception $e) {
// Just going to the next check
}

else if (!($this->is_empty($order->getBillingAddress()->getEmail())))
return $order->getBillingAddress()->getEmail();
try {
if (!($this->is_empty($order->getShippingAddress()->getEmail())))
return $order->getShippingAddress()->getEmail();
} catch (\Exception $e) {
// Just going to the next check
}

try {
if (!($this->is_empty($order->getBillingAddress()->getEmail())))
return $order->getBillingAddress()->getEmail();
} catch (\Exception $e) {
// Just going to the next check
}

try {
if (!($this->is_empty($order->getCustomerId())))
return $this->_customer->load($order->getCustomerId())->getEmail();
} catch (\Exception $e) {
// Just skipping an email
}

else if (!($this->is_empty($order->getCustomerId())))
return $this->_customer->load($order->getCustomerId())->getEmail();

return '';
}

Expand Down
8 changes: 3 additions & 5 deletions Observer/ConfigObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public function getSettings()
$globalSettings = new \stdClass();
$globalSettings->source = 'Magento2';
$globalSettings->pluginVersion = $this->_helper->getGeneralConfigValue('ReleaseNumber');
$globalSettings->magentoVersion = 'Magento-'.$this->getVersion();
$id = 0;
$globalSettings->version = 'Magento-'.$this->getVersion();
$stores = $this->getStores();
$globalSettings->stores = array();
foreach ($stores as $store) {
$general = new \stdClass();
$general->key = trim($this->_helper->getGeneralConfigValue('key'));
Expand All @@ -59,9 +59,7 @@ public function getSettings()
$settings = new \stdClass();
$settings->general = $general;
$settings->trustbox = $trustbox;

$globalSettings->$id = $settings;
$id = $id + 1;
array_push($globalSettings->stores, $settings);
}

return $globalSettings;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "trustpilot/module-reviews",
"description": "The Trustpilot Review extension makes it simple and easy for merchants to collect reviews from their customers to power their marketing efforts, increase sales conversion, build their online reputation and draw business insights.",
"type": "magento2-module",
"version": "1.0.201",
"version": "1.0.214",
"license": [
"OSL-3.0"
],
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ConnectUrl>https://ecommerce-invitations.b2b.trustpilot.com/#/magento</ConnectUrl>
<SnippetUrl>https://businessapp.b2b.trustpilot.com/#/integrations/trustbox/library</SnippetUrl>
<PreviewUrl>//ecommplugins-scripts.trustpilot.com/</PreviewUrl>
<ReleaseNumber>1.0.201</ReleaseNumber>
<ReleaseNumber>1.0.214</ReleaseNumber>
<key></key>
</general>
</trustpilotGeneral>
Expand Down

0 comments on commit c65989b

Please sign in to comment.