Skip to content

Commit

Permalink
Merge pull request #23 from NicolasBarbey/main
Browse files Browse the repository at this point in the history
fix send confirmation email
  • Loading branch information
NicolasBarbey authored Jun 9, 2023
2 parents d4edb9c + 3213f08 commit 0147990
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
9 changes: 0 additions & 9 deletions Config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@
<loop name="cmcic.check.rights" class="CmCIC\Loop\CheckRightsLoop" />
</loops>

<services>
<service id="cmcic.confirmation.email" class="CmCIC\EventListeners\SendConfirmationEmail">
<argument type="service" id="mailer"/>
<argument type="service" id="event_dispatcher"/>

<tag name="kernel.event_subscriber"/>
</service>
</services>

<hooks>
<hook id="cmcic.back.hook" class="CmCIC\Hook\HookManager">
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfigure" />
Expand Down
4 changes: 2 additions & 2 deletions Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<language>fr_FR</language>
<language>en_US</language>
</languages>
<version>1.4.5</version>
<version>2.0.0</version>
<authors>
<author>
<name>Thelia</name>
Expand All @@ -28,6 +28,6 @@
</author>
</authors>
<type>payment</type>
<thelia>2.2.0</thelia>
<thelia>2.5.0</thelia>
<stability>prod</stability>
</module>
14 changes: 10 additions & 4 deletions EventListeners/SendConfirmationEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@
namespace CmCIC\EventListeners;

use CmCIC\CmCIC;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Log\Tlog;

class SendConfirmationEmail implements EventSubscriberInterface
{
protected EventDispatcherInterface $dispatcher;

public function __construct(EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
}

/**
* @param OrderEvent $event
*
Expand All @@ -39,16 +46,15 @@ public function sendConfirmationEmail(OrderEvent $event)

/**
* @param OrderEvent $event
* @param EventDispatcher $dispatcher
* @throws \Propel\Runtime\Exception\PropelException
*/
public function updateStatus(OrderEvent $event, EventDispatcher $dispatcher)
public function updateStatus(OrderEvent $event)
{
$order = $event->getOrder();
if ($order->isPaid() && $order->getPaymentModuleId() == CmCIC::getModuleId()) {
// Send confirmation email if required.
if (CmCIC::getConfigValue('send_confirmation_message_only_if_paid')) {
$dispatcher->dispatch($event, TheliaEvents::ORDER_SEND_CONFIRMATION_EMAIL);
$this->dispatcher->dispatch($event, TheliaEvents::ORDER_SEND_CONFIRMATION_EMAIL);
}

Tlog::getInstance()->debug("Confirmation email sent to customer " . $order->getCustomer()->getEmail());
Expand Down

0 comments on commit 0147990

Please sign in to comment.