Skip to content

Commit

Permalink
Merge pull request #47 from Invertus/DGS-162
Browse files Browse the repository at this point in the history
Dgs 162 do not throw error when cart is missing on tracking url print
  • Loading branch information
arturas-bes authored Dec 13, 2021
2 parents ae17ab2 + 186d30f commit a4dee3a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@
- Bugfix when parcel terminal unconditionally changed to first selection while searching.
- Upgrade added to avoid error when client upgrades modules and does not delete cache.
- Bugfix when parcel tracking validation was called from prestashop core. Fall back to universal legacy function
- Logic to execute code further if error occurs on tracking email send.
- Bugfix when parcel terminal form is always visible in order
- Translatable string added when no option available, translations updated for all baltic languages for pickup select.



1 change: 1 addition & 0 deletions config/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ services:
arguments:
- '@invertus.dpdbaltics.factory.parcel_tracking_url_factory'
- '@dpdbaltics'
- '@invertus.dpdbaltics.logger.logger'

invertus.dpdbaltics.service.carrier.prestashop_carrier_regeneration_handler:
class: 'Invertus\dpdBaltics\Service\Carrier\PrestashopCarrierRegenerationHandler'
Expand Down
20 changes: 16 additions & 4 deletions src/Service/Email/Handler/ParcelTrackingEmailHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Invertus\dpdBaltics\Exception\ParcelEmailException;
use Invertus\dpdBaltics\Factory\ContextFactory;
use Invertus\dpdBaltics\Factory\ParcelTrackingUrlFactory;
use Invertus\dpdBaltics\Logger\Logger;
use Mail;
use Module;
use Validate;
Expand All @@ -16,17 +17,25 @@ class ParcelTrackingEmailHandler
*/
private $trackingUrlFactory;


/**
* @var Module
*/
private $module;

/**
* @var Logger
*/
private $logger;

public function __construct(
ParcelTrackingUrlFactory $trackingUrlFactory,
Module $module
Module $module,
Logger $logger
) {
$this->trackingUrlFactory = $trackingUrlFactory;
$this->module = $module;
$this->logger = $logger;
}

/**
Expand All @@ -36,17 +45,20 @@ public function __construct(
public function handle($idOrder, $parcelNumbers)
{
if (!$idOrder) {
throw new ParcelEmailException('Could not retrieve order');
$this->logger->log(Logger::ERROR, 'Could not retrieve order');
return false;
}
$order = $this->getOrder($idOrder);

if (empty($parcelNumbers)) {
throw new ParcelEmailException('Could not retrieve parcel number, failed to format email');
$this->logger->log(Logger::ERROR, 'Could not retrieve parcel number, failed to format email ID Order: '. $idOrder);
return false;
}

$cart = $this->getCartByOrderId($idOrder);

if (!Validate::isLoadedObject($cart)) {
throw new ParcelEmailException('Could not retrieve order cart information');
$this->logger->log(Logger::ERROR, 'Could not retrieve order cart information ID Order: '. $idOrder);
}

ContextFactory::getSmarty()->assign([
Expand Down

0 comments on commit a4dee3a

Please sign in to comment.