**
* send order confirmation mail
* @access public
*/
{
$variables = $this->eventManager->filter(
‚Shopware_Modules_Order_SendMail_FilterVariables‘,
$variables,
array(‚subject‘ => $this)
);
$shopContext = $this->contextService->getShopContext();
$context = array(
‚sOrderDetails‘ => $variables[„sOrderDetails“],
‚billingaddress‘ => $variables[„billingaddress“],
‚shippingaddress‘ => $variables[„shippingaddress“],
‚additional‘ => $variables[„additional“],
‚sTaxRates‘ => $variables[„sTaxRates“],
‚sShippingCosts‘ => $variables[„sShippingCosts“],
‚sAmount‘ => $variables[„sAmount“],
‚sAmountNet‘ => $variables[„sAmountNet“],
‚sOrderNumber‘ => $variables[„ordernumber“],
‚sOrderDay‘ => $variables[„sOrderDay“],
‚sOrderTime‘ => $variables[„sOrderTime“],
‚sComment‘ => $variables[„sComment“],
‚attributes‘ => $variables[„attributes“],
‚sCurrency‘ => $this->sSYSTEM->sCurrency[„currency“],
‚sLanguage‘ => $shopContext->getShop()->getId(),
‚sSubShop‘ => $shopContext->getShop()->getId(),
‚sEsd‘ => $variables[„sEsd“],
‚sNet‘ => $this->sNet,
);
// Support for individual payment means with custom-tables
if ($variables[„additional“][„payment“][„table“]) {
$paymentTable = $this->db->fetchRow("
SELECT * FROM {$variables[„additional“][„payment“][„table“]}
WHERE userID=?",
array($variables[„additional“][„user“][„id“])
);
$context[„sPaymentTable“] = $paymentTable ? : array();
} else {
$context[„sPaymentTable“] = array();
}
if ($variables[„sDispatch“]) {
$context[‚sDispatch‘] = $variables[„sDispatch“];
}
if ($variables[‚sBookingID‘]) {
$context[‚sBookingID‘] = $variables[„sBookingID“];
}
$mail = null;
if ($event = $this->eventManager->notifyUntil(
‚Shopware_Modules_Order_SendMail_Create‘,
array(
‚subject‘ => $this,
‚context‘ => $context,
‚variables‘ => $variables,
)
)) {
$mail = $event->getReturn();
}
if (!($mail instanceof \Zend_Mail)) {
$mail = Shopware()->TemplateMail()->createMail(‚sORDER‘, $context);
}
$mail->addTo($this->sUserData[„additional“][„user“][„email“]);
if (!$this->config->get(„sNO_ORDER_MAIL“)) {
$mail->addBcc($this->config->get(‚sMAIL‘));
}
$mail = $this->eventManager->filter(‚Shopware_Modules_Order_SendMail_Filter‘, $mail, array(
‚subject‘ => $this,
‚context‘ => $context,
‚variables‘ => $variables,
));
if (!($mail instanceof \Zend_Mail)) {
return;
}
$this->eventManager->notify(
‚Shopware_Modules_Order_SendMail_BeforeSend‘,
array(
‚subject‘ => $this,
‚mail‘ => $mail,
‚context‘ => $context,
‚variables‘ => $variables,
)
);
$shouldSendMail = !(bool) $this->eventManager->notifyUntil(
‚Shopware_Modules_Order_SendMail_Send‘,
array(
‚subject‘ => $this,
‚mail‘ => $mail,
‚context‘ => $context,
‚variables‘ => $variables,
)
);
if ($shouldSendMail && $this->config->get(‚sendOrderMail‘)) {
$mail->send();
}
}