Back to PhocacartOrderStatus class

Method canSendEmail

public static
canSendEmail
(mixed $orderToken, mixed $common)

Method canSendEmail - Source code

public static function canSendEmail($orderToken, $common)
{
    $app = Factory::getApplication();
    if (!$app->isClient('administrator')) {
        // Frontend
        // Check if we can send email to customer
        $canSend = 0;
        $user = PhocacartUser::getUser();
        $guest = PhocacartUserGuestuser::getGuestUser();
        // $orderToken is set in case we will not check the user:
        // - in case of guest users
        // - in case of payment method server contacts the server to change the status
        if ($orderToken != '' && $orderToken == $common->order_token && $guest) {
            $canSend = 1;
            // User is guest - not logged in user run this script
            //PhocacartLog::add(4, 'CHECK', (int)$orderId, 'Guest User');
        } else {
            if ($orderToken != '' && $orderToken == $common->order_token) {
                $canSend = 1;
                // Payment method server returned status which will change order status - payment method runs this script
                //PhocacartLog::add(4, 'CHECK', (int)$orderId, 'Payment method');
            } else {
                if ($user->id == $common->user_id) {
                    $canSend = 1;
                    // User is the customer who made the order
                    //PhocacartLog::add(4, 'CHECK', (int)$orderId, 'Registered User');
                }
            }
        }
    } else {
        // Backend
        $canSend = 1;
    }
    return $canSend;
}