Skip to content

Commit

Permalink
Fixes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Dec 7, 2021
1 parent 2652966 commit 30d7270
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/EventListener/PurchaseSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
use Setono\SyliusGoogleAdsPlugin\Exception\WrongOrderTypeException;
use Setono\SyliusGoogleAdsPlugin\Factory\ConversionFactoryInterface;
use Setono\SyliusGoogleAdsPlugin\Model\ConversionActionInterface;
use Setono\SyliusGoogleAdsPlugin\Model\OrderInterface;
use Setono\SyliusGoogleAdsPlugin\Repository\ConversionActionRepositoryInterface;
use Sylius\Component\Core\Model\OrderInterface as BaseOrderInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
Expand Down Expand Up @@ -80,9 +82,14 @@ public function track(RequestEvent $requestEvent): void
return;
}

/** @var OrderInterface|BaseOrderInterface $order */
$order = $this->orderRepository->find($orderId);
WrongOrderTypeException::assert($order);

if ($order->getGoogleClickId() === null) {
return;
}

$channel = $order->getChannel();
Assert::notNull($channel);

Expand Down

0 comments on commit 30d7270

Please sign in to comment.