@@ -242,7 +242,8 @@ private static function sendOrderEmail(object $order, PhocacartOrderView $orderV
242242 $ recipient = '' ; // Customer/Buyer
243243 $ recipientOthers = '' ; // others
244244 $ bcc = '' ;
245- $ notificationResult = -1 ;
245+ //$notificationResult = -1;
246+ $ notificationResult = 0 ;
246247
247248 if ($ notifyUser ) {
248249 if (self ::canSendEmail ($ orderToken , $ order )) {
@@ -262,7 +263,8 @@ private static function sendOrderEmail(object $order, PhocacartOrderView $orderV
262263 }
263264
264265 if (!JoomlaMailHelper::isEmailAddress ($ recipient ) && !JoomlaMailHelper::isEmailAddress ($ recipientOthers )) {
265- return 0 ;
266+ PhocacartLog::add (2 , 'Sending email - ERROR ' , $ order ->id , Text::_ ('COM_PHOCACART_ERROR ' ). ' (Incorrect recipient email) ' );
267+ return -1 ;
266268 }
267269
268270 // ------------------------
@@ -357,10 +359,12 @@ private static function sendOrderEmail(object $order, PhocacartOrderView $orderV
357359
358360 $ notificationResult = 1 ;
359361 } else {
360- $ notificationResult = 0 ;
362+ PhocacartLog::add (2 , 'Sending email - ERROR ' , $ order ->id , Text::_ ('COM_PHOCACART_ERROR ' ). ' (Error when sending email using mailer) ' );
363+ $ notificationResult = -1 ;
361364 }
362365 } catch (\Exception $ exception ) {
363- $ notificationResult = 0 ;
366+ $ notificationResult = -1 ;
367+ PhocacartLog::add (2 , 'Sending email - ERROR ' , $ order ->id , Text::_ ('COM_PHOCACART_ERROR ' ). ' ( ' .Text::_ ($ exception ->errorMessage ()).') ' );
364368 Factory::getApplication ()->enqueueMessage (Text::_ ($ exception ->errorMessage ()), 'warning ' );
365369 }
366370 }
@@ -649,6 +653,7 @@ public static function changeStatus($orderId, $statusId, $orderToken = '',
649653 $ stockMovements = '99 ' , $ changeUserGroup = '99 ' , $ changePointsNeeded = '99 ' , $ changePointsReceived = '99 ' , $ emailSendFormat = '99 '
650654 )
651655 {
656+
652657 // ORDER INFO
653658 $ orderView = new PhocacartOrderView ();
654659 $ order = $ orderView ->getItemCommon ($ orderId );
@@ -674,7 +679,7 @@ public static function changeStatus($orderId, $statusId, $orderToken = '',
674679 throw new PhocaCartException ('Invalid status ID ' );
675680 }
676681
677- if ($ notifyUser == 99 ) {
682+ if ($ notifyUser === 99 ) {
678683 if ($ status ['email_customer ' ] == 2 ) {
679684 $ notifyUser = !PhocacartPos::isPos ();
680685 } else {
@@ -684,17 +689,17 @@ public static function changeStatus($orderId, $statusId, $orderToken = '',
684689 $ notifyUser = !!$ notifyUser ;
685690 }
686691
687- if ($ notifyOthers == 99 ) {
692+ if ($ notifyOthers === 99 ) {
688693 $ notifyOthers = !!$ status ['email_others ' ];
689694 } else {
690695 $ notifyOthers = !!$ notifyOthers ;
691696 }
692697
693- if ($ emailSend == 99 ) {
698+ if ($ emailSend === 99 ) {
694699 $ emailSend = $ status ['email_send ' ];
695700 }
696701
697- if ($ emailSendFormat == 99 ) {
702+ if ($ emailSendFormat === 99 ) {
698703 $ emailSendFormat = $ status ['email_send_format ' ];
699704 }
700705
@@ -738,7 +743,6 @@ public static function changeStatus($orderId, $statusId, $orderToken = '',
738743 self ::updateDownload ($ order ->id , $ status ['download ' ]);
739744 $ notificationResult = self ::sendOrderEmail ($ order , $ orderView , $ status , $ addresses , $ orderToken , $ notifyUser , $ notifyOthers , (int )$ emailSend , !!$ emailSendFormat );
740745 self ::sendGiftEmail ($ order , $ orderView , $ status , $ addresses , $ orderToken );
741-
742746 return $ notificationResult ;
743747 }
744748
0 commit comments