public static function order($name, $email = '', $phone = '', $address = '', $comment = '', $adminNotifyTplID = 'admin_purchase_notify', $customerNotifyTplID = 'user_purchase_notify') { global $db; $user = \cf\User::getLoggedIn(); $productList = ''; $products = \cf\api\cart\getList(); if (!array_key_exists('contents', $products) || !count($products['contents'])) { return false; } $tpl = new MailTemplate('order'); execQuery("\n\t\t\tINSERT INTO cf_orders (created,customer_name, customer_email, customer_phone, customer_address, customer_comments, comments)\n\t\t\tVALUES(NOW(),:name, :email, :phone, :address, :comments, :contents)", array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comments' => $comment, 'contents' => $tpl->parseBody(array('cart' => $products)))); $orderId = $db->lastInsertId(); $msgParams = array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comment' => $comment, 'order' => $orderId, 'total' => $products['total'], 'products' => $products['contents']); \cf\api\cart\clear(); $mail = new \PHPMailer(); $mail->CharSet = 'UTF-8'; if ($adminNotifyTplID) { $tpl = new MailTemplate($adminNotifyTplID); $mail->Subject = $tpl->parseSubject($msgParams); $mail->MsgHTML($tpl->parseBody($msgParams)); foreach ($tpl->recipients() as $address) { $mail->addAddress($address); } $mail->Send(); } $mail->clearAddresses(); if ($customerNotifyTplID && $email) { $tpl = new MailTemplate($customerNotifyTplID); $mail->Subject = $tpl->parseSubject($msgParams); $mail->MsgHTML($tpl->parseBody($msgParams)); $mail->addAddress($email); $mail->Send(); } return $orderId; }