Bonjour,
J'essaye de ne pas envoyer de mail de confirmation de commande avant que la commande soit considérée comme payé. Je suis allé voir dans les fichiers du module Atos et le fichier dans Atos/EventListeners/SendConfirmationEmail.php à la class SendConfirmationEmail
La class d'origine est :
class SendConfirmationEmail implements EventSubscriberInterface
{
/**
* @var ParserInterface
*/
protected $parser;
/**
* @var MailerFactory
*/
protected $mailer;
public function __construct(ParserInterface $parser, MailerFactory $mailer)
{
$this->parser = $parser;
$this->mailer = $mailer;
}
public function updateStatus(OrderEvent $event)
{
$atos = new Atos();
$order = $event->getOrder();
if ($order->isPaid() && $atos->isPaymentModuleFor($order)) {
$this->mailer->sendEmailToCustomer(
Atos::CONFIRMATION_MESSAGE_NAME,
$order->getCustomer(),
[
'order_id' => $order->getId(),
'order_ref' => $order->getRef()
]
);
Tlog::getInstance()->debug("Confirmation email sent to customer " . $order->getCustomer()->getEmail());
}
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
*
* @return array The event names to listen to
*
* @api
*/
public static function getSubscribedEvents()
{
return [
TheliaEvents::ORDER_UPDATE_STATUS => ["updateStatus", 128]
];
}
}
Apaprement le mail ne devrait s'envoyer que si on a la condition ispaid. MAis ce n'est pas le cas.
J'ai tenté une modification mais il n'y a pas eu de changement de comportement :
class SendConfirmationEmail implements EventSubscriberInterface
{
/**
* @var ParserInterface
*/
protected $parser;
/**
* @var MailerFactory
*/
protected $mailer;
public function __construct(ParserInterface $parser, MailerFactory $mailer)
{
$this->parser = $parser;
$this->mailer = $mailer;
}
public function updateStatus(OrderEvent $event)
{
$atos = new Atos();
$order = $event->getOrder();
if (! $order->isPaid()) {
$event->stopPropagation();
}
elseif ($order->isPaid() && $atos->isPaymentModuleFor($order)) {
$this->mailer->sendEmailToCustomer(
Atos::CONFIRMATION_MESSAGE_NAME,
$order->getCustomer(),
[
'order_id' => $order->getId(),
'order_ref' => $order->getRef()
]
);
Tlog::getInstance()->debug("Confirmation email sent to customer " . $order->getCustomer()->getEmail());
}
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
*
* @return array The event names to listen to
*
* @api
*/
public static function getSubscribedEvents()
{
return [
TheliaEvents::ORDER_UPDATE_STATUS => ["updateStatus", 128]
];
}
}
JE dois mal m'y prendre et peut être que je ne regarde pas au bon endroit ?
Last edited by Milo1986 (27-11-2015 19:31:53)