Beispiel #1
0
 /**
  * Internal helper function to check if the order or payment status has been changed. If one
  * of the status changed, the function will create a status mail. If the passed autoSend parameter
  * is true, the created status mail will be send directly.
  * @param Order   $order
  * @param \Shopware\Models\Order\Status $statusBefore
  * @param \Shopware\Models\Order\Status $clearedBefore
  * @param boolean $autoSend
  * @return array
  */
 private function checkOrderStatus($order, $statusBefore, $clearedBefore, $autoSend)
 {
     if ($order->getOrderStatus()->getId() !== $statusBefore->getId() || $order->getPaymentStatus()->getId() !== $clearedBefore->getId()) {
         //status or cleared changed?
         if ($order->getOrderStatus()->getId() !== $statusBefore->getId()) {
             $mail = $this->getMailForOrder($order->getId(), $order->getOrderStatus()->getId());
         } else {
             $mail = $this->getMailForOrder($order->getId(), $order->getPaymentStatus()->getId());
         }
         //mail object created and auto send activated, then send mail directly.
         if (is_object($mail['mail']) && $autoSend === "true") {
             $result = Shopware()->Modules()->Order()->sendStatusMail($mail['mail']);
             //check if send mail was successfully.
             $mail['data']['sent'] = is_object($result);
         }
         return $mail['data'];
     } else {
         return null;
     }
 }