Ejemplo n.º 1
0
 /**
  * Send the order notification email
  */
 public function SendNotification()
 {
     $emails = array();
     $this->_message = $this->BuildEmailMessage();
     $this->_email = $this->GetValue("emailaddress");
     if (empty($this->_email)) {
         return;
     }
     $emails = preg_split('#[,\\s]+#si', $this->_email, -1, PREG_SPLIT_NO_EMPTY);
     // Create a new email object through which to send the email
     $store_name = GetConfig('StoreName');
     require_once ISC_BASE_PATH . "/lib/email.php";
     $obj_email = GetEmailClass();
     $obj_email->Set('CharSet', GetConfig('CharacterSet'));
     $obj_email->From(GetConfig('OrderEmail'), $store_name);
     $obj_email->Set("Subject", sprintf(GetLang('NEmailSubjectLine'), $this->GetOrderId(), $store_name, FormatPrice($this->GetOrderTotal(), false, true, false, GetDefaultCurrency())));
     $obj_email->AddBody("html", $this->_message);
     // Add all recipients
     foreach ($emails as $email) {
         $obj_email->AddRecipient($email, "", "h");
     }
     $email_result = $obj_email->Send();
     if ($email_result['success']) {
         $result = array("outcome" => "success", "message" => sprintf(GetLang('EmailNotificationSentUser'), implode("<br />", $emails)));
     } else {
         $result = array("outcome" => "fail", "message" => GetLang('NEmailSendingFailed'));
     }
     return $result;
 }
Ejemplo n.º 2
0
	public function SendNewReturnNotification($return, $items)
	{
		// Get the customer's details
		$query = sprintf("SELECT custconfirstname, custconlastname, custconemail FROM [|PREFIX|]customers WHERE customerid='%d'", $return['retcustomerid']);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		$customer = $GLOBALS['ISC_CLASS_DB']->Fetch($result);

		$GLOBALS['ReturnId'] = $return['returnid'];

		$GLOBALS['CustomerFirstName'] = $customer['custconfirstname'];
		$GLOBALS['CustomerName'] = $customer['custconfirstname'] . " " . $customer['custconlastname'];
		$GLOBALS['CustomerEmail'] = $customer['custconemail'];

		$emailTemplate = FetchEmailTemplateParser();

		$GLOBALS['SNIPPETS']['ReturnItems'] = '';
		foreach($items as $product) {
			$GLOBALS['ProductName'] = $product['retprodname'];
			$GLOBALS['ProductId'] = $product['retprodid'];
			$GLOBALS['ProductQty'] = $product['retprodqty'];
			$GLOBALS['SNIPPETS']['ReturnItems'] .= $emailTemplate->GetSnippet("ReturnConfirmationItem");
		}

		$GLOBALS['ReturnReason'] = $return['retreason'];
		if(!$GLOBALS['ReturnReason']) {
			$GLOBALS['ReturnReason'] = GetLang('NA');
		}

		$GLOBALS['ReturnAction'] = $return['retaction'];
		if(!$GLOBALS['ReturnAction']) {
			$GLOBALS['ReturnAction'] = GetLang('NA');
		}
		$GLOBALS['ReturnStatus'] = $this->_FetchReturnStatus($return['retstatus']);

		$GLOBALS['ReturnComments'] = nl2br($return['retcomment']);

		$emailTemplate->SetTemplate("return_notification_email");
		$message = $emailTemplate->ParseTemplate(true);

		// Create a new email API object to send the email
		$store_name = str_replace("&#39;", "'", GetConfig('StoreName'));

		require_once(ISC_BASE_PATH . "/lib/email.php");
		$obj_email = GetEmailClass();
		$obj_email->Set('CharSet', GetConfig('CharacterSet'));
		$obj_email->From(GetConfig('OrderEmail'), $store_name);
		$obj_email->Set("Subject", sprintf(GetLang('NotificationNewReturnRequestOn'), $store_name));
		$obj_email->AddBody("html", $message);

		if ($return['retvendorid']) {
			$query = "SELECT vendoremail FROM [|PREFIX|]vendors WHERE vendorid = " . $return['retvendorid'];
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			if ($vendor = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$recipient = $vendor['vendoremail'];
			}
			else {
				return false;
			}
		}
		else {
			$recipient = GetConfig('OrderEmail');
		}

		$obj_email->AddRecipient($recipient, "", "h");
		$email_result = $obj_email->Send();

		// If the email was sent ok, show a confirmation message
		if($email_result['success']) {
			return true;
		}
		else {
			// Email error
			return false;
		}
	}
Ejemplo n.º 3
0
/**
 *	Send an email notification to a customer when the status of their order changes.
 *
 * @param int The ID of the order to email the invoice for.
 * @return boolean True if successful.
 */
function EmailOnStatusChange($orderId, $status)
{
    // Load the order
    $order = GetOrder($orderId);
    // Load the customer we'll be contacting
    if ($order['ordcustid'] > 0) {
        $customer = GetCustomer($order['ordcustid']);
        $GLOBALS['ViewOrderStatusLink'] = '<a href="' . $GLOBALS['ShopPathSSL'] . '/orderstatus.php">' . GetLang('ViewOrderStatus') . '</a>';
    } else {
        $customer['custconemail'] = $order['ordbillemail'];
        $customer['custconfirstname'] = $order['ordbillfirstname'];
        $GLOBALS['ViewOrderStatusLink'] = '';
    }
    if (empty($customer['custconemail'])) {
        return;
    }
    // All prices in the emailed invoices will be shown in the default currency of the store
    $defaultCurrency = GetDefaultCurrency();
    $statusName = GetOrderStatusById($status);
    $GLOBALS['ISC_LANG']['OrderStatusChangedHi'] = sprintf(GetLang('OrderStatusChangedHi'), isc_html_escape($customer['custconfirstname']));
    $GLOBALS['ISC_LANG']['OrderNumberStatusChangedTo'] = sprintf(GetLang('OrderNumberStatusChangedTo'), $order['orderid'], $statusName);
    $GLOBALS['OrderTotal'] = FormatPrice($order['ordtotalamount'], false, true, false, $defaultCurrency, true);
    $GLOBALS['DatePlaced'] = CDate($order['orddate']);
    if ($order['orderpaymentmethod'] === 'giftcertificate') {
        $GLOBALS['PaymentMethod'] = GetLang('PaymentGiftCertificate');
    } else {
        if ($order['orderpaymentmethod'] === 'storecredit') {
            $GLOBALS['PaymentMethod'] = GetLang('PaymentStoreCredit');
        } else {
            $GLOBALS['PaymentMethod'] = $order['orderpaymentmethod'];
        }
    }
    $query = "\n\t\tSELECT COUNT(*)\n\t\tFROM [|PREFIX|]order_products\n\t\tWHERE ordprodtype='digital'\n\t\tAND orderorderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'\n\t";
    $numDigitalProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
    $emailTemplate = FetchEmailTemplateParser();
    $GLOBALS['SNIPPETS']['CartItems'] = "";
    if (OrderIsComplete($status) && $numDigitalProducts > 0) {
        $query = "\n\t\t\tSELECT *\n\t\t\tFROM [|PREFIX|]order_products op INNER JOIN [|PREFIX|]products p ON (op.ordprodid = p.productid)\n\t\t\tWHERE ordprodtype='digital'\n\t\t\tAND orderorderid='" . $GLOBALS['ISC_CLASS_DB']->Quote($orderId) . "'\n\t\t";
        $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
        while ($product_row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
            $GLOBALS['ProductOptions'] = '';
            $GLOBALS['ProductQuantity'] = $product_row['ordprodqty'];
            $GLOBALS['ProductName'] = isc_html_escape($product_row['ordprodname']);
            $GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');
            $DownloadItemEncrypted = $GLOBALS['ISC_CLASS_ACCOUNT']->EncryptDownloadKey($product_row['orderprodid'], $product_row['ordprodid'], $orderId, $order['ordtoken']);
            $GLOBALS['DownloadsLink'] = $GLOBALS['ShopPathSSL'] . '/account.php?action=download_item&amp;data=' . $DownloadItemEncrypted;
            $GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("StatusCompleteDownloadItem");
        }
    }
    if (empty($GLOBALS['SNIPPETS']['CartItems'])) {
        $emailTemplate->SetTemplate("order_status_email");
    } else {
        $emailTemplate->SetTemplate("order_status_downloads_email");
    }
    $message = $emailTemplate->ParseTemplate(true);
    // Create a new email API object to send the email
    $store_name = GetConfig('StoreName');
    $subject = GetLang('OrderStatusChangedSubject');
    require_once ISC_BASE_PATH . "/lib/email.php";
    $obj_email = GetEmailClass();
    $obj_email->Set('CharSet', GetConfig('CharacterSet'));
    $obj_email->From(GetConfig('OrderEmail'), $store_name);
    $obj_email->Set('Subject', $subject);
    $obj_email->AddBody("html", $message);
    $obj_email->AddRecipient($customer['custconemail'], '', "h");
    $email_result = $obj_email->Send();
    if ($email_result['success']) {
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 4
0
	/**
	* call this when a job needs to be terminated due to an error
	*
	* @param string $message
	* @return void
	*/
	protected function _errorExport($message)
	{
		$this->_logDebug('error');

		// notify user that the export has been aborted due to an error
		$replacements = array(
			'type' => $this->_type,
		);

		$obj_email = GetEmailClass();
		$obj_email->Set('CharSet', GetConfig('CharacterSet'));
		$obj_email->From(GetConfig('OrderEmail'), GetConfig('StoreName'));
		$obj_email->Set("Subject", GetLang("EmailIntegration_Export_Error_Email_Subject", $replacements));
		$obj_email->AddRecipient($this->_getExportData('owner:email'), "", "h");

		$GLOBALS['EmailHeader'] = GetLang("EmailIntegration_Export_Error_Email_Subject", $replacements);

		$GLOBALS['EmailIntegration_Export_Error_Email_Message_1'] = GetLang('EmailIntegration_Export_Error_Email_Message_1', $replacements);
		$GLOBALS['EmailIntegration_Export_Error_Email_Error_Heading'] = GetLang('EmailIntegration_Export_Error_Email_Error_Heading', $replacements);
		$GLOBALS['EmailIntegration_Export_Error_Email_Error'] = $message;
		$GLOBALS['EmailIntegration_Export_Error_Email_Error_Footer'] = GetLang('EmailIntegration_Export_Error_Email_Error_Footer', $replacements);

		$emailTemplate = FetchEmailTemplateParser();
		$emailTemplate->SetTemplate("email_integration_export_failed");
		$message = $emailTemplate->ParseTemplate(true);

		$obj_email->AddBody("html", $message);
		$email_result = $obj_email->Send();

		$this->_removeExport();
	}
Ejemplo n.º 5
0
	/**
	* Notify admin by email of a failed subscription
	*
	* @param Interspire_EmailIntegration_Subscription $subscription Failed subscription
	* @param array $merge Failed merge data
	* @param string $errorMessage
	*/
	public function notifyAdmin(Interspire_EmailIntegration_Subscription $subscription, $merge, $errorMessage)
	{
		// can't rely on ISC_ADMIN_ENGINE or admin lang stuff from here because this code may be run by the task manager
		$languagePath = ISC_BASE_PATH . '/language/' . GetConfig('Language') . '/admin';
		ParseLangFile($languagePath . '/common.ini');
		ParseLangFile($languagePath . '/settings.emailintegration.ini');

		$replacements = array(
			'provider' => $this->GetName(),
			'time' => isc_date(GetConfig('ExtendedDisplayDateFormat'), time()),
		);

		$GLOBALS['EmailHeader'] = GetLang("NoCheckoutProvidersSubject");
		$GLOBALS['EmailMessage'] = sprintf(GetLang("NoCheckoutProvidersErrorLong"), $GLOBALS['ShopPath']);
		$GLOBALS['SubscriptionDetails'] = '';

		$GLOBALS['EmailIntegrationNotice_Header'] = GetLang('EmailIntegrationNotice_Header', $replacements);

		$GLOBALS['EmailIntegrationNotice_Intro'] = GetLang('EmailIntegrationNotice_Intro', $replacements);
		$GLOBALS['EmailIntegrationNotice_Error'] = GetLang('EmailIntegrationNotice_Error', $replacements);
		$GLOBALS['EmailIntegrationNotice_Message'] = $errorMessage;
		$GLOBALS['EmailIntegrationNotice_Time'] = GetLang('EmailIntegrationNotice_Time', $replacements);
		$GLOBALS['EmailIntegrationNotice_Details'] = GetLang('EmailIntegrationNotice_Details', $replacements);
		$GLOBALS['EmailIntegrationNotice_Type'] = $subscription->getSubscriptionTypeLang();

		$details = new Xhtml_Table();

		$row = new Xhtml_Tr();
		$row->appendChild(new Xhtml_Th(GetLang('EmailIntegrationNotice_Columns_Provider', $replacements)));
		$row->appendChild(new Xhtml_Th(GetLang('EmailIntegrationNotice_Columns_Subscription', $replacements)));
		$details->appendChild($row);

		$row = new Xhtml_Tr();
		$row->appendChild(new Xhtml_Td($this->getEmailProviderFieldId()));
		$row->appendChild(new Xhtml_Td($subscription->getSubscriptionEmail()));
		$details->appendChild($row);

		foreach ($merge as $field => $value) {
			$row = new Xhtml_Tr();
			$row->appendChild(new Xhtml_Td($field));
			$row->appendChild(new Xhtml_Td($value));
			$details->appendChild($row);
		}

		$GLOBALS['EmailIntegrationNotice_Subscription'] = $details->render();

		$GLOBALS['EmailIntegrationNotice_CommonCauses'] = GetLang('EmailIntegrationNotice_CommonCauses', $replacements);

		$GLOBALS['EmailIntegrationNotice_Cause1_Intro'] = GetLang('EmailIntegrationNotice_Cause1_Intro', $replacements);
		$GLOBALS['EmailIntegrationNotice_Cause1_Detail'] = GetLang('EmailIntegrationNotice_Cause1_Detail', $replacements);
		$GLOBALS['EmailIntegrationNotice_Cause2_Intro'] = GetLang('EmailIntegrationNotice_Cause2_Intro', $replacements);
		$GLOBALS['EmailIntegrationNotice_Cause2_Detail'] = GetLang('EmailIntegrationNotice_Cause2_Detail', $replacements);
		$GLOBALS['EmailIntegrationNotice_Cause3_Intro'] = GetLang('EmailIntegrationNotice_Cause3_Intro', $replacements);
		$GLOBALS['EmailIntegrationNotice_Cause3_Detail'] = GetLang('EmailIntegrationNotice_Cause3_Detail', $replacements);
		$GLOBALS['EmailIntegrationNotice_Cause4_Intro'] = GetLang('EmailIntegrationNotice_Cause4_Intro', $replacements);
		$GLOBALS['EmailIntegrationNotice_Cause4_Detail'] = GetLang('EmailIntegrationNotice_Cause4_Detail', $replacements);
		$GLOBALS['EmailIntegrationNotice_Cause5_Intro'] = GetLang('EmailIntegrationNotice_Cause5_Intro', $replacements);
		$GLOBALS['EmailIntegrationNotice_Cause5_Detail'] = GetLang('EmailIntegrationNotice_Cause5_Detail', $replacements);

		$GLOBALS['EmailIntegrationNotice_Closing'] = GetLang('EmailIntegrationNotice_Closing', $replacements);

		$emailTemplate = FetchEmailTemplateParser();
		$emailTemplate->SetTemplate("email_integration_notice_email");
		$message = $emailTemplate->ParseTemplate(true);

		$obj_email = GetEmailClass();
		$obj_email->Set('CharSet', GetConfig('CharacterSet'));
		$obj_email->From(GetConfig('OrderEmail'), GetConfig('StoreName'));
		$obj_email->Set("Subject", GetLang("EmailIntegrationEmailSubject"));
		$obj_email->AddBody("html", $message);
		$obj_email->AddRecipient(GetConfig('AdminEmail'), "", "h");
		$email_result = $obj_email->Send();
	}
Ejemplo n.º 6
0
 /**
  *	Save the new password for the customer's account
  */
 private function SaveNewPassword()
 {
     if (isset($_GET['c']) && isset($_GET['t'])) {
         $customerId = (int) isc_html_escape($_GET['c']);
         $customerHash = isc_html_escape($_GET['t']);
         $query = "SELECT *\n\t\t\t\t\t\t\tFROM [|PREFIX|]customers\n\t\t\t\t\t\t\tWHERE customerid=" . $customerId;
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $customer = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         // Can't find them in the database
         if (!isId($customerId) || !$customer) {
             return $this->ResetPassword("invalid_link", 1);
         }
         // Also check to see if our salted string matches this customer
         if (!CustomerHashCheck($customerHash, $customer['customerpasswordresettoken'], $customerId)) {
             return $this->ResetPassword("invalid_link", 1);
         }
         // OK, all the arguments are cool. Now we generate a password for them
         $password = GenerateReadablePassword();
         $updateData = array('custpassword' => md5($password), 'customerpasswordresettoken' => '', 'customerpasswordresetemail' => '');
         if ($GLOBALS['ISC_CLASS_DB']->UpdateQuery('customers', $updateData, 'customerid=' . $customerId) === false) {
             return $this->ResetPassword("internal_error", 1);
         }
         // Send the email
         $store_name = GetConfig('StoreName');
         $email_message = sprintf(GetLang('ForgotPasswordEmailConfirmed'), $store_name, $password);
         // Create a new email API object to send the email
         require_once ISC_BASE_PATH . "/lib/email.php";
         $obj_email = GetEmailClass();
         $obj_email->Set('CharSet', GetConfig('CharacterSet'));
         $obj_email->From(GetConfig('OrderEmail'), $store_name);
         $obj_email->Set("Subject", sprintf(GetLang('ForgotPasswordEmailConfirmedSubject'), $store_name));
         $obj_email->AddBody("html", $email_message);
         $obj_email->AddRecipient($customer['customerpasswordresetemail'], "", "h");
         $email_result = $obj_email->Send();
         if ($email_result['success']) {
             return $this->ShowLoginPage(sprintf(GetLang('ForgotPasswordChanged'), $customer['customerpasswordresetemail']), 0, true);
         } else {
             return $this->ResetPassword("internal_error", 1);
         }
     } else {
         $this->ShowLoginPage();
     }
 }
Ejemplo n.º 7
0
		/**
		*	Send a contact form from a page
		*/
		public function SendContactForm()
		{
			// If the pageid or captcha is not set then just show the page and exit
			if (!isset($_POST['page_id']) || !isset($_POST['captcha'])) {
				$this->ShowPage();
				return;
			}

			// Load the captcha class
			$GLOBALS['ISC_CLASS_CAPTCHA'] = GetClass('ISC_CAPTCHA');

			// Load the form variables
			$page_id = (int)$_POST['page_id'];
			$this->_SetPageData($page_id);

			$captcha = $_POST['captcha'];

			if(GetConfig('CaptchaEnabled') == 0) {
				$captcha_check = true;
			}
			else {
				if(isc_strtolower($captcha) == isc_strtolower($GLOBALS['ISC_CLASS_CAPTCHA']->LoadSecret())) {
					// Captcha validation succeeded
					$captcha_check = true;
				}
				else {
					// Captcha validation failed
					$captcha_check = false;
				}
			}

			if($captcha_check) {
				// Valid captcha, let's send the form. The template used for the contents of the
				// email is page_contact_email.html
				$from = @$_POST['contact_fullname'];
				$GLOBALS['PageTitle'] = $this->_pagetitle;
				$GLOBALS['FormFieldList'] = "";

				$emailTemplate = FetchEmailTemplateParser();

				// Which fields should we include in the form?
				$fields = $this->_pagerow['pagecontactfields'];

				if(is_numeric(isc_strpos($fields, "fullname"))) {
					$GLOBALS['FormField'] = GetLang('ContactName');
					$GLOBALS['FormValue'] = isc_html_escape($_POST['contact_fullname']);
					$GLOBALS['FormFieldList'] .= $emailTemplate->GetSnippet("ContactFormField");
				}

				$GLOBALS['FormField'] = GetLang('ContactEmail');
				$GLOBALS['FormValue'] = isc_html_escape($_POST['contact_email']);
				$GLOBALS['FormFieldList'] .= $emailTemplate->GetSnippet("ContactFormField");

				if(is_numeric(isc_strpos($fields, "companyname"))) {
					$GLOBALS['FormField'] = GetLang('ContactCompanyName');
					$GLOBALS['FormValue'] = isc_html_escape($_POST['contact_companyname']);
					$GLOBALS['FormFieldList'] .= $emailTemplate->GetSnippet("ContactFormField");
				}

				if(is_numeric(isc_strpos($fields, "phone"))) {
					$GLOBALS['FormField'] = GetLang('ContactPhone');
					$GLOBALS['FormValue'] = isc_html_escape($_POST['contact_phone']);
					$GLOBALS['FormFieldList'] .= $emailTemplate->GetSnippet("ContactFormField");
				}

				if(is_numeric(isc_strpos($fields, "orderno"))) {
					$GLOBALS['FormField'] = GetLang('ContactOrderNo');
					$GLOBALS['FormValue'] = isc_html_escape($_POST['contact_orderno']);
					$GLOBALS['FormFieldList'] .= $emailTemplate->GetSnippet("ContactFormField");
				}

				if(is_numeric(isc_strpos($fields, "rma"))) {
					$GLOBALS['FormField'] = GetLang('ContactRMANo');
					$GLOBALS['FormValue'] = isc_html_escape($_POST['contact_rma']);
					$GLOBALS['FormFieldList'] .= $emailTemplate->GetSnippet("ContactFormField");
				}

				$GLOBALS['Question'] = nl2br(isc_html_escape($_POST['contact_question']));

				$GLOBALS['ISC_LANG']['ContactPageFormSubmitted'] = sprintf(GetLang('ContactPageFormSubmitted'), $GLOBALS['PageTitle']);

				$emailTemplate->SetTemplate("page_contact_email");
				$message = $emailTemplate->ParseTemplate(true);

				// Send the email
				require_once(ISC_BASE_PATH . "/lib/email.php");
				$obj_email = GetEmailClass();
				$obj_email->Set('CharSet', GetConfig('CharacterSet'));
				$obj_email->From($_POST['contact_email'], $from);
				$obj_email->ReplyTo = $_POST['contact_email'];
				$obj_email->Set("Subject", GetLang('ContactPageFormSubmitted'));
				$obj_email->AddBody("html", $message);
				$obj_email->AddRecipient($this->_pagerow['pageemail'], "", "h");
				$email_result = $obj_email->Send();

				// If the email was sent ok, show a confirmation message
				$GLOBALS['MessageTitle'] = $GLOBALS['PageTitle'];

				if($email_result['success']) {
					$GLOBALS['MessageIcon'] = "IcoInfo";
					$GLOBALS['MessageText'] = sprintf(GetLang('PageFormSent'), $GLOBALS['ShopPath']);
				}
				else {
					// Email error
					$GLOBALS['MessageIcon'] = "IcoError";
					$GLOBALS['MessageText'] = GetLang('PageFormNotSent');
				}

				$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("message");
				$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
			}
			else {
				// Bad captcha, take them back to the form
				$this->ShowPage();
			}
		}
Ejemplo n.º 8
0
 private function SaveNewOfferMessage()
 {
     if (isset($_POST['orderId']) && isset($_POST['subject']) && isset($_POST['message'])) {
         $order_id = (int) $_POST['orderId'];
         // Does this user have permission to view this order?
         $order = GetOrder($order_id);
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $order['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             FlashMessage(GetLang('Unauthorized'), MSG_ERROR, 'index.php?ToDo=viewOffers');
         }
         $subject = $_POST['subject'];
         $message = $_POST['message'];
         // Save the message to the database first
         $newMessage = array("messagefrom" => "admin", "subject" => $subject, "message" => $message, "datestamp" => time(), "messageorderid" => $order_id, "messagestatus" => "unread", "staffuserid" => $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUserId(), "isflagged" => 0);
         $message_id = $GLOBALS['ISC_CLASS_DB']->InsertQuery("offer_messages", $newMessage);
         if ($message_id) {
             $message_id = $GLOBALS['ISC_CLASS_DB']->LastId();
             // Log this action
             $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($message_id, $order_id);
             // Now send a notification email to the customer
             $customer_email = $this->GetCustomerEmailByOrderId($order_id);
             // Create a new email API object to send the email
             $store_name = GetConfig('StoreName');
             $emailTemplate = FetchEmailTemplateParser();
             $emailTemplate->SetTemplate("ordermessage_notification");
             $message = $emailTemplate->ParseTemplate(true);
             require_once ISC_BASE_PATH . "/lib/email.php";
             $obj_email = GetEmailClass();
             $obj_email->Set('CharSet', GetConfig('CharacterSet'));
             $obj_email->From(GetConfig('OrderEmail'), $store_name);
             $obj_email->Set("Subject", $subject);
             $obj_email->AddBody("html", $message);
             $obj_email->AddRecipient($customer_email, "", "h");
             $email_result = $obj_email->Send();
             if ($email_result['success']) {
                 $this->ViewOfferMessages(GetLang('OrderMessageSentOK'), MSG_SUCCESS);
             } else {
                 $this->ViewOfferMessages(GetLang('OrderMessagesSentEmailFailed'), MSG_ERROR);
             }
         } else {
             $this->ViewOfferMessages(GetLang('OrderMessagesSentFailed'), MSG_ERROR);
         }
     }
 }
Ejemplo n.º 9
0
 /**
  * Build the contents for the order confirmation page. This function sets up everything to be used by
  * the order confirmation on the express checkout page as well as the ConfirmOrder page when using a
  * multi step checkout.
  */
 public function BuildOrderConfirmation()
 {
     //alandy.check customer email.
     $GLOBALS['Hasemailflag'] = "no";
     /*$sql="select customerid from [|PREFIX|]customers where custconemail='".$_SESSION['CHECKOUT']['account_email']."'";
      	$query=$GLOBALS['ISC_CLASS_DB']->Query($sql);
      	while($rs=$GLOBALS['ISC_CLASS_DB']->Fetch($query)){
      		$GLOBALS['Hasemailflag']="yes";
      	}*/
     if ($_SESSION['Haslogin'] == 1) {
         $GLOBALS['Hasemailflag'] = "no";
     }
     if (!GetConfig('ShowMailingListInvite')) {
         $GLOBALS['HideMailingListInvite'] = 'none';
     }
     // Do we need to show the special offers & discounts checkbox and should they
     // either of the newsletter checkboxes be ticked by default?
     if (GetConfig('MailAutomaticallyTickNewsletterBox')) {
         $GLOBALS['NewsletterBoxIsTicked'] = 'checked="checked"';
     }
     // Is Interspire Email Marketer integrated?
     if (GetConfig('MailXMLAPIValid') && GetConfig('UseMailerForOrders') && GetConfig('MailOrderList') > 0) {
         // Yes, should we tick the speical offers & discounts checkbox by default?
         if (GetConfig('MailAutomaticallyTickOrderBox')) {
             $GLOBALS['OrderBoxIsTicked'] = 'checked="checked"';
         }
     } else {
         $GLOBALS['HideOrderCheckBox'] = "none";
     }
     if (isset($_REQUEST['ordercomments'])) {
         $GLOBALS['OrderComments'] = $_REQUEST['ordercomments'];
     }
     // Now we check if we have an incoming coupon or gift certificate code to apply
     if (isset($_REQUEST['couponcode']) && $_REQUEST['couponcode'] != '') {
         $code = trim($_REQUEST['couponcode']);
         // Were we passed a gift certificate code?
         if (isc_strlen($code) == GIFT_CERTIFICATE_LENGTH && gzte11(ISC_LARGEPRINT)) {
             $cart = GetClass('ISC_MAKEAOFFER');
             if ($cart->api->ApplyGiftCertificate($code)) {
                 // If successful show a message
                 $GLOBALS['CheckoutSuccessMsg'] = GetLang('GiftCertificateAppliedToCart');
             } else {
                 $GLOBALS['CheckoutErrorMsg'] = implode('<br />', $cart->api->GetErrors());
             }
         } else {
             $cart = GetClass('ISC_MAKEAOFFER');
             if ($cart->api->ApplyCoupon($code)) {
                 $cart->api->ReapplyCouponsFromCart();
                 //Added by Simha temp fix to avoid having multiple times coupon for same item
                 $cart->api->UpdateCartInformation();
                 // Coupon code applied successfully
                 $GLOBALS['CheckoutSuccessMsg'] = GetLang('CouponAppliedToCart');
             } else {
                 $GLOBALS['CheckoutErrorMsg'] = implode('<br />', $cart->api->GetErrors());
             }
         }
     }
     $GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');
     // Determine what we'll be showing for the redeem gift certificate/coupon code box
     if (gzte11(ISC_LARGEPRINT)) {
         $GLOBALS['RedeemTitle'] = GetLang('RedeemGiftCertificateOrCoupon');
         $GLOBALS['RedeemIntro'] = GetLang('RedeemGiftCertificateorCouponIntro');
     } else {
         $GLOBALS['RedeemTitle'] = GetLang('RedeemCouponCode');
         $GLOBALS['RedeemIntro'] = GetLang('RedeemCouponCodeIntro');
     }
     $GLOBALS['HideCheckoutError'] = "none";
     $GLOBALS['HidePaymentOptions'] = "";
     $GLOBALS['HideUseCoupon'] = '';
     // if the provider list html is set in session then use it as the payment provider options.
     // it's normally set in payment modules when it's required.
     if (isset($_SESSION['CHECKOUT']['ProviderListHTML'])) {
         $GLOBALS['HidePaymentProviderList'] = "";
         $GLOBALS['HidePaymentOptions'] = "";
         $GLOBALS['PaymentProviders'] = $_SESSION['CHECKOUT']['ProviderListHTML'];
         $GLOBALS['StoreCreditPaymentProviders'] = $_SESSION['CHECKOUT']['ProviderListHTML'];
         $GLOBALS['CheckoutWith'] = "";
     } else {
         // Get a list of checkout providers
         $checkoutProviders = GetCheckoutModulesThatCustomerHasAccessTo(true);
         // If no checkout providers are set up, send an email to the store owner and show an error message
         if (empty($checkoutProviders)) {
             $GLOBALS['HideConfirmOrderPage'] = "none";
             $GLOBALS['HideCheckoutError'] = '';
             $GLOBALS['HideTopPaymentButton'] = "none";
             $GLOBALS['HidePaymentProviderList'] = "none";
             $GLOBALS['CheckoutErrorMsg'] = GetLang('NoCheckoutProviders');
             $GLOBALS['NoCheckoutProvidersError'] = sprintf(GetLang("NoCheckoutProvidersErrorLong"), $GLOBALS['ShopPath']);
             $GLOBALS['EmailHeader'] = GetLang("NoCheckoutProvidersSubject");
             $GLOBALS['EmailMessage'] = sprintf(GetLang("NoCheckoutProvidersErrorLong"), $GLOBALS['ShopPath']);
             $emailTemplate = FetchEmailTemplateParser();
             $emailTemplate->SetTemplate("general_email");
             $message = $emailTemplate->ParseTemplate(true);
             require_once ISC_BASE_PATH . "/lib/email.php";
             $obj_email = GetEmailClass();
             $obj_email->Set('CharSet', GetConfig('CharacterSet'));
             $obj_email->From(GetConfig('OrderEmail'), GetConfig('StoreName'));
             $obj_email->Set("Subject", GetLang("NoCheckoutProvidersSubject"));
             $obj_email->AddBody("html", $message);
             $obj_email->AddRecipient(GetConfig('AdminEmail'), "", "h");
             $email_result = $obj_email->Send();
         } else {
             if (count($checkoutProviders) > 1) {
                 $GLOBALS['HideTopPaymentButton'] = "none";
                 $GLOBALS['HideCheckoutError'] = "none";
             } else {
                 $GLOBALS['HidePaymentProviderList'] = "none";
                 $GLOBALS['HideCheckoutError'] = "none";
                 $GLOBALS['HidePaymentOptions'] = "none";
                 list(, $provider) = each($checkoutProviders);
                 if (method_exists($provider['object'], 'ShowPaymentForm') && !isset($_SESSION['CHECKOUT']['ProviderListHTML'])) {
                     $GLOBALS['ExpressCheckoutLoadPaymentForm'] = 'ExpressCheckout.ShowSingleMethodPaymentForm();';
                 }
                 if ($provider['object']->GetPaymentType() == PAYMENT_PROVIDER_OFFLINE) {
                     $GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton();";
                 }
                 $GLOBALS['CheckoutWith'] = $provider['object']->GetDisplayName();
             }
         }
         // Build the list of payment provider options
         $GLOBALS['PaymentProviders'] = $GLOBALS['StoreCreditPaymentProviders'] = "";
         foreach ($checkoutProviders as $provider) {
             $GLOBALS['ProviderChecked'] = '';
             if (count($checkoutProviders) == 1) {
                 $GLOBALS['ProviderChecked'] = 'checked="checked"';
             }
             $GLOBALS['ProviderId'] = $provider['object']->GetId();
             $GLOBALS['ProviderName'] = isc_html_escape($provider['object']->GetDisplayName());
             $GLOBALS['ProviderType'] = $provider['object']->GetPaymentType("text");
             if (method_exists($provider['object'], 'ShowPaymentForm')) {
                 $GLOBALS['ProviderPaymentFormClass'] = 'ProviderHasPaymentForm';
             } else {
                 $GLOBALS['ProviderPaymentFormClass'] = '';
             }
             $GLOBALS['PaymentFieldPrefix'] = '';
             $GLOBALS['PaymentProviders'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutProviderOption");
             $GLOBALS['PaymentFieldPrefix'] = 'credit_';
             $GLOBALS['StoreCreditPaymentProviders'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutProviderOption");
         }
     }
     // Are we coming back to this page for a particular reason?
     if (isset($_SESSION['REDIRECT_TO_CONFIRMATION_MSG'])) {
         $GLOBALS['HideCheckoutError'] = '';
         $GLOBALS['CheckoutErrorMsg'] = $_SESSION['REDIRECT_TO_CONFIRMATION_MSG'];
         unset($_SESSION['REDIRECT_TO_CONFIRMATION_MSG']);
     }
     // Get a summary of the order
     $orderSummary = $this->CalculateOrderSummary();
     // Start building the summary of all of the items in the order
     $GLOBALS['SNIPPETS']['CartItems'] = '';
     /* Baskaran */
     $compprice = 0;
     $comptotal = 0;
     /* Code Ends */
     foreach ($orderSummary['products'] as $cartKey => $product) {
         $GLOBALS['ProductQuantity'] = $product['quantity'];
         $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['price']);
         $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($product['total']);
         // If the item in the cart is a gift certificate, we need to show a special type of row
         if (isset($product['type']) && $product['type'] == "giftcertificate") {
             $GLOBALS['GiftCertificateName'] = isc_html_escape($product['data']['prodname']);
             $GLOBALS['GiftCertificateTo'] = isc_html_escape($product['certificate']['to_name']);
             //$GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutCartItemGiftCertificate");
         } else {
             $GLOBALS['ProductAvailability'] = isc_html_escape($product['data']['prodavailability']);
             $GLOBALS['ItemId'] = $product['data']['productid'];
             // If this is a discounted price (from a coupon) override the product price to the was/now version
             if (isset($product['discount_price']) && $product['discount_price'] != $product['original_price']) {
                 $GLOBALS['ProductPrice'] = sprintf("<s class='CartStrike'>%s</s> %s", CurrencyConvertFormatPrice($product['original_price']), CurrencyConvertFormatPrice($product['price']));
             }
             // Is this product a variation?
             $GLOBALS['ProductOptions'] = '';
             if (isset($product['options']) && !empty($product['options'])) {
                 $GLOBALS['ProductOptions'] .= "<br /><small>(";
                 $comma = '';
                 foreach ($product['options'] as $name => $value) {
                     if (!trim($name) || !trim($value)) {
                         continue;
                     }
                     $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                     $comma = ', ';
                 }
                 $GLOBALS['ProductOptions'] .= ")</small>";
             }
             $GLOBALS['EventDate'] = '';
             if (isset($product['event_date'])) {
                 $GLOBALS['EventDate'] = '<div style="font-style: italic; font-size:11px; padding-left:10px">' . $product['event_name'] . ': ' . isc_date('M jS Y', $product['event_date']) . '</div>';
             }
             $GLOBALS['HideGiftWrapping'] = 'display: none';
             $GLOBALS['HideGiftMessagePreview'] = 'display: none';
             $GLOBALS['GiftWrappingName'] = '';
             $GLOBALS['GiftMessagePreview'] = '';
             if (isset($product['wrapping_name'])) {
                 $GLOBALS['HideGiftWrapping'] = '';
                 $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping_name']);
                 if (isset($product['wrapping_message'])) {
                     if (isc_strlen($product['wrapping_message']) > 30) {
                         $product['wrapping_message'] = substr($product['wrapping_message'], 0, 27) . '...';
                     }
                     $GLOBALS['GiftMessagePreview'] = isc_html_escape($product['wrapping_message']);
                     if ($product['wrapping_message']) {
                         $GLOBALS['HideGiftMessagePreview'] = '';
                     }
                 }
             }
             //create configurable product fields on order confirmation page with the data posted from add to cart page
             $GLOBALS['CartProductFields'] = '';
             if (isset($product['productFields'])) {
                 require_once ISC_BASE_PATH . '/includes/display/OfferContent.php';
                 ISC_MAKEAOFFERCONTENT_PANEL::GetProductFieldDetails($product['productFields'], $cartKey);
             }
             $GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']);
             $GLOBALS['ProductQuantity'] = 1;
             $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($_SESSION['the_offered_price']);
             $GLOBALS['ProductTotal'] = $GLOBALS['ProductPrice'];
             $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutCartItem");
         }
     }
     // Do we have a shipping price to show?
     if ($orderSummary['digitalOrder'] == 0) {
         $GLOBALS['ShippingCost'] = CurrencyConvertFormatPrice($orderSummary['shippingCost']);
         $GLOBALS['ShippingMethod'] = sprintf("%s %s %s", isc_html_escape($orderSummary['shippingProvider']), GetLang('For'), $GLOBALS['ShippingCost']);
         $GLOBALS['HideShoppingCartShippingCost'] = '';
         $GLOBALS['ShippingProvider'] = isc_html_escape($orderSummary['shippingProvider']);
         if (count($orderSummary['shippingAddresses']) == 1) {
             $address = current($orderSummary['shippingAddresses']);
             $GLOBALS['ShippingAddress'] = $GLOBALS['ISC_CLASS_ACCOUNT']->FormatShippingAddress($address);
         } else {
             if (count($orderSummary['shippingAddresses']) > 1) {
                 $GLOBALS['ShippingAddress'] = '<em>(Order will be shipped to multiple addresses)</em>';
             } else {
                 $GLOBALS['ShippingAddress'] = GetLang('NA');
             }
         }
         // Show the shipping details
         $GLOBALS['HideShippingDetails'] = '';
     } else {
         $GLOBALS['HideShippingDetails'] = 'display: none';
         $GLOBALS['HideShoppingCartShippingCost'] = 'none';
         $GLOBALS['ShippingAddress'] = GetLang('NotRequiredForDigitalDownloads');
         $GLOBALS['ShippingMethod'] = GetLang('ShippingImmediateDownload');
     }
     if (isset($orderSummary['billingAddressId'])) {
         $GLOBALS['BillingAddress'] = $GLOBALS['ISC_CLASS_ACCOUNT']->GetAndFormatShippingAddressById($orderSummary['billingAddressId']);
     } else {
         $GLOBALS['BillingAddress'] = $GLOBALS['ISC_CLASS_ACCOUNT']->FormatShippingAddress($orderSummary['billingAddress']);
     }
     // Do we have a handling cost to show?
     if (isset($orderSummary['handlingCost']) && $orderSummary['handlingCost'] > 0) {
         $GLOBALS['HandlingCost'] = CurrencyConvertFormatPrice($orderSummary['handlingCost']);
     } else {
         $GLOBALS['HideShoppingCartHandlingCost'] = 'none';
     }
     // Format the item total
     $GLOBALS['ItemTotal'] = CurrencyConvertFormatPrice($orderSummary['itemTotal']);
     if ($orderSummary['wrappingCost'] > 0) {
         $GLOBALS['GiftWrappingTotal'] = CurrencyConvertFormatPrice($orderSummary['wrappingCost']);
     } else {
         $GLOBALS['HideGiftWrappingTotal'] = 'display: none';
     }
     // Hide everything related to tax by default
     $GLOBALS['HideShoppingCartTaxCost'] = "none";
     $GLOBALS['HideShoppingCartIncludedTaxCost'] = "none";
     // Do we have any tax we need to show?
     if ($orderSummary['taxCost'] > 0) {
         $taxLines = "";
         $taxLang = "";
         if ($orderSummary['taxIncluded']) {
             $taxLang = "Included";
         }
         // get the taxes from the addresses and merge them if they are from the same tax rate
         $taxes = array();
         foreach ($orderSummary['vendors'] as $vendorId => $addresses) {
             foreach ($addresses as $addressId => $addressInfo) {
                 $taxId = $addressInfo['taxId'];
                 if (isset($taxes[$taxId])) {
                     $taxes[$taxId]['taxCost'] += $addressInfo['taxCost'];
                 } else {
                     $taxes[$taxId] = array('taxName' => $addressInfo['taxName'], 'taxCost' => $addressInfo['taxCost'], 'taxRate' => $addressInfo['taxRate']);
                 }
             }
         }
         $GLOBALS['SNIPPETS']['TaxLines'] = "";
         // generate lines for each tax rate
         foreach ($taxes as $taxId => $tax) {
             $GLOBALS['TaxName'] = isc_html_escape(sprintf(GetLang($taxLang . 'TaxLine'), $tax['taxName'], $tax['taxRate'] / 1));
             $GLOBALS['TaxCost'] = CurrencyConvertFormatPrice($tax['taxCost']);
             $taxLines .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutTaxLine");
         }
         // if more than one tax rate is used, display a total line
         if (count($taxes) > 1) {
             $GLOBALS['TaxName'] = isc_html_escape(GetLang($taxLang . 'TotalTax'));
             $GLOBALS['TaxCost'] = CurrencyConvertFormatPrice($orderSummary['taxCost']);
             $taxLines .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutTaxLine");
         }
         $GLOBALS['SNIPPETS']['TaxLines'] = "";
         $GLOBALS['SNIPPETS']['IncludedTax'] = "";
         // are we displaying the tax before the total or after as included tax?
         if ($orderSummary['taxIncluded']) {
             $GLOBALS['SNIPPETS']['IncludedTax'] = $taxLines;
         } else {
             $GLOBALS['SNIPPETS']['TaxLines'] = $taxLines;
         }
     }
     // Format the grand total of the order
     $GLOBALS['ItemTotal'] = CurrencyConvertFormatPrice($_SESSION['the_offered_price']);
     $GLOBALS['TotalCost'] = CurrencyConvertFormatPrice($_SESSION['the_offered_price'] + $orderSummary['shippingCost']);
     $_SESSION['makeaoffertotal'] = $GLOBALS['TotalCost'];
     $GLOBALS['HideAdjustedTotal'] = "none";
     $GLOBALS['SNIPPETS']['GiftCertificates'] = '';
     if ($orderSummary['adjustedTotal'] != $orderSummary['total']) {
         $GLOBALS['HideAdjustedTotal'] = '';
         $GLOBALS['AdjustedTotalCost'] = $orderSummary['adjustedTotal'];
     }
     $GLOBALS['SNIPPETS']['Coupons'] = '';
     if (count($orderSummary['coupons'])) {
         foreach ($orderSummary['coupons'] as $coupon) {
             $GLOBALS['CouponId'] = $coupon['couponid'];
             $GLOBALS['CouponCode'] = $coupon['couponcode'];
             // percent coupon
             if ($coupon['coupontype'] == 1) {
                 $discount = $coupon['discount'] . "%";
             } else {
                 $discount = CurrencyConvertFormatPrice($coupon['discount']);
             }
             $GLOBALS['CouponDiscount'] = $discount;
             $GLOBALS['SNIPPETS']['Coupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ConfirmOrderCoupon");
         }
     }
     // If we have any gift certificates, list those too
     if (!empty($orderSummary['giftCertificates'])) {
         foreach ($orderSummary['giftCertificates'] as $certificate) {
             $GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']);
             $GLOBALS['GiftCertificateId'] = $certificate['giftcertid'];
             $GLOBALS['GiftCertificateBalance'] = CurrencyConvertFormatPrice($certificate['giftcertbalance']);
             $GLOBALS['GiftCertificateRemaining'] = CurrencyConvertFormatPrice($certificate['balanceremaining']);
             $GLOBALS['CertificateAmountUsed'] = CurrencyConvertFormatPrice($certificate['amountused']);
             $GLOBALS['SNIPPETS']['GiftCertificates'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ConfirmOrderGiftCertificate");
         }
     }
     // If the order total comes to $0.00, then we don't show the payment options and a lot of other things (because they have nothing to pay)
     if ($orderSummary['adjustedTotal'] == 0) {
         $GLOBALS['HidePaymentOptions'] = "none";
         $GLOBALS['HideUseCoupon'] = 'none';
         $GLOBALS['HidePaymentProviderList'] = "none";
         $GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton(); ExpressCheckout.UncheckPaymentProvider();";
     }
     // Does the customer have any store credit they can use?
     $GLOBALS['HideUseStoreCredit'] = "none";
     $GLOBALS['HideRemainingStoreCredit'] = "none";
     $customer = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerDataByToken();
     if ($customer['custstorecredit'] > 0) {
         $GLOBALS['HidePaymentOptions'] = "";
         $GLOBALS['StoreCredit'] = CurrencyConvertFormatPrice($customer['custstorecredit']);
         $GLOBALS['HideUseStoreCredit'] = "";
         $GLOBALS['HidePaymentProviderList'] = "none";
         // The customer has enough store credit to pay for the entirity of this order
         if ($customer['custstorecredit'] >= $orderSummary['adjustedTotal']) {
             $GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton();";
             $GLOBALS['HideLimitedCreditWarning'] = "none";
             $GLOBALS['HideLimitedCreditPaymentOption'] = "none";
             $GLOBALS['HideCreditPaymentMethods'] = "none";
             $GLOBALS['RemainingCredit'] = $customer['custstorecredit'] - $orderSummary['adjustedTotal'];
             if ($GLOBALS['RemainingCredit'] > 0) {
                 $GLOBALS['HideRemainingStoreCredit'] = '';
                 $GLOBALS['RemainingCredit'] = CurrencyConvertFormatPrice($GLOBALS['RemainingCredit']);
             }
         } else {
             $GLOBALS['Remaining'] = CurrencyConvertFormatPrice($orderSummary['adjustedTotal'] - $customer['custstorecredit']);
             if (count($checkoutProviders) == 1) {
                 $GLOBALS['CheckoutStoreCreditWarning'] = sprintf(GetLang('CheckoutStoreCreditWarning2'), $GLOBALS['Remaining'], $GLOBALS['CheckoutWith']);
                 $GLOBALS['HideLimitedCreditPaymentOption'] = "none";
             } else {
                 $GLOBALS['CheckoutStoreCreditWarning'] = GetLang('CheckoutStoreCreditWarning');
             }
             $GLOBALS['ISC_LANG']['CreditPaymentMethod'] = sprintf(GetLang('CreditPaymentMethod'), $GLOBALS['Remaining']);
         }
         if (count($checkoutProviders) > 1) {
             $GLOBALS['CreditAlt'] = GetLang('CheckoutCreditAlt');
         } else {
             if (count($checkoutProviders) <= 1 && isset($GLOBALS['CheckoutWith'])) {
                 $GLOBALS['CreditAlt'] = sprintf(GetLang('CheckoutCreditAltOneMethod'), $GLOBALS['CheckoutWith']);
             } else {
                 if ($customer['custstorecredit'] >= $orderSummary['adjustedTotal']) {
                     $GLOBALS['HideCreditAltOptionList'] = "none";
                     $GLOBALS['HideConfirmOrderPage'] = "";
                     $GLOBALS['HideTopPaymentButton'] = "none";
                     $GLOBALS['HideCheckoutError'] = "none";
                     $GLOBALS['CheckoutErrorMsg'] = '';
                 }
             }
         }
     }
     // Customer has hit this page before. Delete the existing pending order
     // The reason we do a delete is if they're hitting this page again, something
     // has changed with their order or something has become invalid with it along the way.
     if (isset($_COOKIE['SHOP_ORDER_TOKEN'])) {
         $query = "\n\t\t\t\tSELECT orderid\n\t\t\t\tFROM [|PREFIX|]offers\n\t\t\t\tWHERE ordtoken='" . $GLOBALS['ISC_CLASS_DB']->Quote($_COOKIE['SHOP_ORDER_TOKEN']) . "' AND ordstatus=0\n\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($offer = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             if ($offer['orderid']) {
                 $this->DeletePendingOffer($offer['orderid']);
             }
         }
     }
     // Are we showing an error message?
     if (isset($GLOBALS['CheckoutErrorMsg']) && $GLOBALS['CheckoutErrorMsg'] != '') {
         $GLOBALS['HideCheckoutError'] = '';
     } else {
         $GLOBALS['HideCheckoutError'] = "none";
     }
     // Is there a success message to show?
     if (isset($GLOBALS['CheckoutSuccessMsg']) && $GLOBALS['CheckoutSuccessMsg'] != '') {
         $GLOBALS['HideCheckoutSuccess'] = '';
     } else {
         $GLOBALS['HideCheckoutSuccess'] = "none";
     }
     // Save the information about the pending order in the checkout session, we'll be using it when they visit the next page
     $_SESSION['CHECKOUT']['PENDING_DATA'] = array("ITEM_TOTAL" => $orderSummary['itemTotal'], "TAX_COST" => number_format($orderSummary['taxCost'], GetConfig('DecimalPlaces'), ".", ""), "TAX_INCLUDED" => $orderSummary['taxIncluded'], "ORDER_TOTAL" => number_format($orderSummary['total'] - $GLOBALS['ISC_CLASS_MAKEAOFFER']->api->Get('SUBTOTAL_DISCOUNT'), GetConfig('DecimalPlaces'), ".", ""), "GATEWAY_AMOUNT" => number_format($orderSummary['adjustedTotal'], GetConfig('DecimalPlaces'), ".", ""), "GIFTCERTIFICATE_AMOUNT" => number_format($orderSummary['giftCertificateTotal'], GetConfig('DecimalPlaces'), ".", ""));
     // Store information about each vendor in the order
     foreach ($orderSummary['vendors'] as $vendorId => $addressInfo) {
         foreach ($addressInfo as $addressId => $vendorInfo) {
             $_SESSION['CHECKOUT']['PENDING_DATA']['VENDORS'][$vendorId . '_' . $addressId] = array('ITEM_TOTAL' => $vendorInfo['itemTotal'], 'TAX_COST' => number_format($vendorInfo['taxCost'], GetConfig('DecimalPlaces'), ".", ""), 'TAX_RATE' => number_format($vendorInfo['taxRate'], GetConfig('DecimalPlaces'), ".", ""), 'TAX_NAME' => $vendorInfo['taxName'], 'ORDER_TOTAL' => number_format($vendorInfo['total'] - $GLOBALS['ISC_CLASS_MAKEAOFFER']->api->Get('SUBTOTAL_DISCOUNT'), GetConfig('DecimalPlaces'), ".", ""));
         }
     }
     // If this is an anonymous checkout, save that
     if (isset($_POST['anonymousCheckout'])) {
         $_SESSION['CHECKOUT']['PENDING_DATA']['GUEST_CHECKOUT'] = 1;
     } else {
         $_SESSION['CHECKOUT']['PENDING_DATA']['GUEST_CHECKOUT'] = 0;
     }
     // Checkout out as a new customer and wishing to create an account, we need to save those details
     if (!CustomerIsSignedIn()) {
         if (isset($_POST['createAccount']) || GetConfig('GuestCheckoutCreateAccounts')) {
             // If we're automatically creating accounts, assign the user a random password
             $autoAccount = 0;
             if (isset($_POST['billing_Password'])) {
                 $password = $_POST['billing_Password'];
             }
             if (!isset($_POST['createAccount']) && GetConfig('GuestCheckoutCreateAccounts')) {
                 $password = substr(md5(uniqid(true)), 0, 8);
                 $autoAccount = 1;
             }
             if (!isset($_SESSION['CHECKOUT']['CREATE_ACCOUNT']) && isset($_POST['billing_EmailAddress'])) {
                 $_SESSION['CHECKOUT']['CREATE_ACCOUNT'] = 1;
                 $_SESSION['CHECKOUT']['ACCOUNT_DETAILS'] = array('email' => $_POST['billing_EmailAddress'], 'password' => $password, 'firstname' => $_POST['billing_FirstName'], 'lastname' => $_POST['billing_LastName'], 'company' => $_POST['billing_CompanyName'], 'phone' => $_POST['billing_Phone'], 'autoAccount' => $autoAccount);
             }
         } else {
             unset($_SESSION['CHECKOUT']['CREATE_ACCOUNT']);
             unset($_SESSION['CHECKOUT']['ACCOUNT_DETAILS']);
         }
     } else {
         unset($_SESSION['CHECKOUT']['CREATE_ACCOUNT']);
         unset($_SESSION['CHECKOUT']['ACCOUNT_DETAILS']);
     }
     if (GetConfig('EnableOrderComments') == 1) {
         $GLOBALS['HideOrderComments'] = "";
     } else {
         $GLOBALS['HideOrderComments'] = "none";
     }
     if ($GLOBALS['ISC_CLASS_MAKEAOFFER']->api->Get('SUBTOTAL_DISCOUNT') == 0) {
         $GLOBALS['HideOrderDiscount'] = "display : none";
     } else {
         $GLOBALS['OrderDiscount'] = CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_MAKEAOFFER']->api->Get('SUBTOTAL_DISCOUNT'));
         $GLOBALS['HideOrderDiscount'] = "";
     }
     if (GetConfig('EnableOrderTermsAndConditions') == 1) {
         $GLOBALS['HideOrderTermsAndConditions'] = "";
         if (GetConfig('OrderTermsAndConditionsType') == "link") {
             $GLOBALS['AgreeTermsAndConditions'] = GetLang('YesIAgree');
             $GLOBALS['TermsAndConditionsLink'] = "<a href='" . GetConfig('OrderTermsAndConditionsLink') . "' target='_BLANK'>" . strtolower(GetLang('TermsAndConditions')) . "</a>.";
             $GLOBALS['HideTermsAndConditionsTextarea'] = "display:none;";
         } else {
             $GLOBALS['HideTermsAndConditionsTextarea'] = '';
             $GLOBALS['OrderTermsAndConditions'] = GetConfig('OrderTermsAndConditions');
             $GLOBALS['AgreeTermsAndConditions'] = GetLang('AgreeTermsAndConditions');
             $GLOBALS['TermsAndConditionsLink'] = '';
         }
     } else {
         $GLOBALS['HideOrderTermsAndConditions'] = "display:none;";
     }
     $GLOBALS['AdjustedTotalCost'] = CurrencyConvertFormatPrice($orderSummary['adjustedTotal']);
 }
Ejemplo n.º 10
0
 private function SendMail()
 {
     $_GET['product'] = $_REQUEST['product'] = $_POST['productid'];
     // Load the data for this product
     $this->_SetOfferData();
     //zcs=>
     $GLOBALS['ISC_CLASS_CAPTCHA'] = GetClass('ISC_CAPTCHA');
     $captcha = trim($_REQUEST['captcha']);
     if (isc_strtolower($captcha) != isc_strtolower($GLOBALS['ISC_CLASS_CAPTCHA']->LoadSecret())) {
         // Captcha validation failed
         echo "<script language=\"javascript\">alert('Invalid captcha!'); history.back();</script>";
         exit;
     }
     if (!$this->GetProductId()) {
         echo "<script language=\"javascript\">alert('Invalid product!'); history.back();</script>";
         exit;
     }
     //<=zcs
     $subject = "Make an Offer";
     $email = trim($_REQUEST['email']);
     $offer = "\$" . trim($_REQUEST['offer']);
     $producttitle = $_REQUEST['prodtitle'];
     $price = $_REQUEST['price'];
     $state = $_REQUEST['state'];
     if ($state != '0') {
         $statename = $state;
     } else {
         $statename = "State not selected";
     }
     $zipcode = $_REQUEST['zipcode'];
     $comment = $_REQUEST['comments'];
     $content = $this->_message;
     $prodtitle = "&lt;!--PRODUCT-TITLE--&gt;";
     $listedprice = "&lt;!--LISTED-PRICE--&gt;";
     $offeredprice = "&lt;!--OFFERED-PRICE--&gt;";
     $cusemail = "&lt;!--CUSTOMER-EMAIL--&gt;";
     $statetag = "&lt;!--STATE--&gt;";
     $zipcodetag = "&lt;!--ZIPCODE--&gt;";
     $commenttag = "&lt;!--COMMENT--&gt;";
     $title = str_replace($prodtitle, $producttitle, $content);
     $lisprice = str_replace($listedprice, $price, $title);
     $offprice = str_replace($offeredprice, $offer, $lisprice);
     $emailreplace = str_replace($cusemail, $email, $offprice);
     $statereplace = str_replace($statetag, $statename, $emailreplace);
     $zip = str_replace($zipcodetag, $zipcode, $statereplace);
     $message = str_replace($commenttag, $comment, $zip);
     $to = $this->_emailids;
     require_once ISC_BASE_PATH . "/lib/email.php";
     $obj_email = GetEmailClass();
     $obj_email->Set('CharSet', GetConfig('CharacterSet'));
     $obj_email->From(GetConfig('OrderEmail'), $email);
     $obj_email->Set('ReplyTo', $email);
     $obj_email->Set("Subject", $subject);
     $obj_email->AddBody("html", $message);
     $obj_email->AddRecipient($to, "", "h");
     $email_result = $obj_email->Send();
     if ($email_result) {
         header("Location: " . $GLOBALS['ShopPath'] . "/offer.php?product=MailSend");
     }
 }
Ejemplo n.º 11
0
	/**
	* call this when the job reaches the end of its data to list
	*
	* @return void
	*/
	protected function _endListing()
	{
		$this->_logDebug('end');

		$started = (int)$this->_getListingData('started');
		$finished = time();

		$replacements = array(
			'template' => $this->_getListingData('template_name'),
			'success_count' => (int)$this->_getListingData('success_count'),
			'error_count' => (int)$this->_getListingData('error_count'),
			'warning_count' => (int)$this->_getListingData('warning_count'),
			'start' => isc_date(GetConfig('ExtendedDisplayDateFormat'), $started),
			'end' => isc_date(GetConfig('ExtendedDisplayDateFormat'), $finished),
			'total' => (int)$this->_getListingData('actual_processed'),
		);

		// notify user that started export of completion
		$obj_email = GetEmailClass();
		$obj_email->Set('CharSet', GetConfig('CharacterSet'));
		$obj_email->From(GetConfig('OrderEmail'), GetConfig('StoreName'));
		$obj_email->Set("Subject", GetLang("Ebay_Listing_End_Email_Subject", $replacements));
		$obj_email->AddRecipient($this->_getListingData('owner:email'), "", "h");

		$emailTemplate = FetchEmailTemplateParser();
		$emailTemplate->SetTemplate("ebay_listing_finished");

		$emailTemplate->Assign('EmailHeader', GetLang("Ebay_Listing_End_Email_Subject", $replacements));

		$emailTemplate->Assign('Ebay_Listing_End_Email_Message_1', GetLang('Ebay_Listing_End_Email_Message_1', $replacements));
		$emailTemplate->Assign('Ebay_Listing_End_Email_Message_2', GetLang('Ebay_Listing_End_Email_Message_2', $replacements));
		$emailTemplate->Assign('Ebay_Listing_End_Email_Message_3', GetLang('Ebay_Listing_End_Email_Message_3', $replacements));
		$emailTemplate->Assign('Ebay_Listing_End_Email_Message_4', GetLang('Ebay_Listing_End_Email_Message_4', $replacements));

		// process errors
		if ($replacements['error_count']) {
			$errors = $this->_keystore->multiGet($this->_prefix . 'error:*');
			$errorHTML = '';

			$limit = 100; // limit number of errors reported via email to 100
			while (!empty($errors) && $limit) {
				$error = array_pop($errors);
				$error = ISC_JSON::decode($error, true);
				if (!$error) {
					// json decode error?
					continue;
				}

				$errorHTML .= '
					<dt>' . $error['prodname'] . '</dt>
					<dd>' . $error['message'] . '</dd>
					<br />
				';

				$limit--;
			}

			if ($errorHTML) {
				$errorHTML = '<dl>' . $errorHTML . '</dl>';

				// only show the heading if error info was successfully generated
				$emailTemplate->Assign('Ebay_Listing_End_Email_Errors_Heading', GetLang('Ebay_Listing_End_Email_Errors_Heading', $replacements));
				$emailTemplate->Assign('Ebay_Listing_End_Email_Errors', $errorHTML);
			}
		}

		// process warnings
		if ($replacements['warning_count']) {
			$errors = $this->_keystore->multiGet($this->_prefix . 'warning:*');
			$errorHTML = '';

			$limit = 100; // limit number of warnings reported via email to 100
			while (!empty($errors) && $limit) {
				$error = array_pop($errors);
				$error = ISC_JSON::decode($error, true);
				if (!$error) {
					// json decode error?
					continue;
				}

				$errorHTML .= '
					<dt>' . $error['prodname'] . '</dt>
					<dd>' . $error['message'] . '</dd>
					<br />
				';

				$limit--;
			}

			if ($errorHTML) {
				$errorHTML = '<dl>' . $errorHTML . '</dl>';

				// only show the heading if error info was successfully generated
				$emailTemplate->Assign('Ebay_Listing_End_Email_Warnings_Heading', GetLang('Ebay_Listing_End_Email_Warnings_Heading', $replacements));
				$emailTemplate->Assign('Ebay_Listing_End_Email_Warnings', $errorHTML);
			}
		}

		$body = $emailTemplate->ParseTemplate(true);

		$obj_email->AddBody("html", $body);
		$email_result = $obj_email->Send();

		$this->_removeListing();
	}
Ejemplo n.º 12
0
 function sendImageUploaderEmail()
 {
     if ($_POST['sendEmail']) {
         $customerid = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerId();
         $sql1 = "SELECT image_last_upload\n\t\t\t\t\tFROM [|PREFIX|]customers\n\t\t\t\t\tWHERE customerid='" . (int) $customerid . "'";
         $result1 = $GLOBALS['ISC_CLASS_DB']->Query($sql1);
         $uploadNum = $GLOBALS['ISC_CLASS_DB']->FetchOne($result1);
         if ($uploadNum <= 0) {
             // don't send email
             return false;
         } else {
             $subject = 'Upload Image Notification';
             $message = "{$uploadNum} photo(s) have just been uploaded to TruckChamp.com";
             $name = "Administrator";
             $to = GetConfig("ImageUploaderSettingsNotifyEmail");
             require_once ISC_BASE_PATH . "/lib/email.php";
             $obj_email = GetEmailClass();
             $obj_email->Set('CharSet', GetConfig('CharacterSet'));
             $obj_email->From(GetConfig('OrderEmail'), $name);
             $obj_email->Set('ReplyTo', GetConfig('OrderEmail'));
             $obj_email->Set("Subject", $subject);
             $obj_email->AddBody("html", $message);
             $obj_email->AddRecipient($to, "", "h");
             $email_result = $obj_email->Send();
             if ($email_result) {
                 $customerEntity = new ISC_ENTITY_CUSTOMER();
                 $customerEntity->clearImageLastUpload($GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerId());
             } else {
                 return false;
             }
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 13
0
 private function SendRequestByEmail($email)
 {
     //load the template for email, e.g. $email = "*****@*****.**";
     $templateId = 1;
     if (isset($_GET['templateId']) && is_numeric($_GET['templateId'])) {
         $templateId = (int) $_GET['templateId'];
     }
     $message = $this->paserRequestTemplate($templateId, 'email');
     // Create a new email API object to send the email
     $store_name = GetConfig('StoreName');
     $subject = sprintf(GetLang('ReviewRequestEmailSubject'), $store_name);
     require_once ISC_BASE_PATH . "/lib/email.php";
     $obj_email = GetEmailClass();
     $obj_email->Set('CharSet', GetConfig('CharacterSet'));
     $obj_email->From(GetConfig('OrderEmail'), $store_name);
     $obj_email->Set('Subject', $subject);
     $obj_email->AddBody("html", $message);
     $obj_email->AddRecipient($email, "", "h");
     //$obj_email->AddAttachmentData($data, $name);
     $email_result = $obj_email->Send();
     return true;
 }
Ejemplo n.º 14
0
	/**
	 * Sends a reset password request email with a token link
	 *
	 * @param integer $userid  The user ID
	 * @param integer $lockout The timestamp of when this lockout will expire
	 * @param string  $msg     Reference message string
	 *
	 * @param boolean
	 */
	public function sendUnblockRequestEmail($userid, $lockout=0, &$msg='')
	{
		$user = $this->getUserByField('pk_userid', $userid, '*');
		if ($lockout == 0) {
			$lockout = $user['attempt_lockout'];
		}

		// expired?
		if ($lockout < time()) {
			return false;
		}

		// build the link with a reset lockout token
		$storeName = GetConfig('StoreName');
		$token = md5($lockout.$userid);
		$subject =  GetLang('UnblockRequestEmailSubject', array(
			'username' => isc_html_escape($user['username']),
		));
		$message = GetLang('UnblockRequestEmailContent', array(
			'username' => isc_html_escape($user['username']),
			'storeName' => isc_html_escape($storeName),
			'confirmUrl' => GetConfig('ShopPath').'/admin/index.php?ToDo=unblock&step=unblock&t='.$token,
			'unlockTime' => isc_date(GetConfig('ExtendedDisplayDateFormat'), $lockout),
		));

		// send the email
		require_once(ISC_BASE_PATH . "/lib/email.php");
		$obj_email = GetEmailClass();
		$obj_email->Set('CharSet', GetConfig('CharacterSet'));
		$obj_email->From(GetConfig('OrderEmail'), $storeName);
		$obj_email->Set('Subject', $subject);
		$obj_email->AddBody('html', $message);
		$obj_email->AddRecipient(GetConfig('AdminEmail'));
		if(!$obj_email->Send()) {
			$err = GetLang('NoEmailSystem');
			return false;
		}

		$msg = GetLang('SendUnblockRequestEmailSuccess', array(
			'lockoutTime'=> GetConfig('PCILoginLockoutTimeMin'),
		));

		return true;

	}//end sendUnblockRequestEmail()
 /**
  * Email a gift certificate to a defined recipient.
  * This function will email a gift certificate to a recipient. It generates the gift certificate from
  * the selected template and attaches it to the gift certificate email.
  */
 public function SendGiftCertificateEmail($giftCertificate)
 {
     if (!$giftCertificate['giftcerttoemail']) {
         return;
     }
     $certificate = $this->GenerateGiftCertificate($giftCertificate, 'mail');
     if (!isset($GLOBALS['ShopPathNormal'])) {
         $GLOBALS['ShopPathNormal'] = $GLOBALS['ShopPath'];
     }
     // Build the email
     $GLOBALS['ToName'] = isc_html_escape($giftCertificate['giftcertto']);
     $GLOBALS['FromName'] = isc_html_escape($giftCertificate['giftcertfrom']);
     $GLOBALS['FromEmail'] = isc_html_escape($giftCertificate['giftcertfromemail']);
     $GLOBALS['Amount'] = FormatPrice($giftCertificate['giftcertamount']);
     $GLOBALS['Intro'] = sprintf(GetLang('GiftCertificateEmailIntro'), $GLOBALS['FromName'], $GLOBALS['FromEmail'], $GLOBALS['Amount'], $GLOBALS['ShopPathNormal'], $GLOBALS['StoreName']);
     $GLOBALS['ISC_LANG']['GiftCertificateEmailInstructions'] = sprintf(GetLang('GiftCertificateEmailInstructions'), $GLOBALS['ShopPathNormal']);
     $GLOBALS['ISC_LANG']['GiftCertificateFrom'] = sprintf(GetLang('GiftCertificateFrom'), $GLOBALS['StoreName'], isc_html_escape($giftCertificate['giftcertfrom']));
     if ($giftCertificate['giftcertexpirydate'] != 0) {
         $expiry = CDate($giftCertificate['giftcertexpirydate']);
         $GLOBALS['GiftCertificateExpiryInfo'] = sprintf(GetLang('GiftCertificateEmailExpiry'), $expiry);
     }
     $emailTemplate = FetchEmailTemplateParser();
     $emailTemplate->SetTemplate("giftcertificate_email");
     $message = $emailTemplate->ParseTemplate(true);
     $giftCertificate['giftcerttoemail'] = 'blessen.babu@clariontechnologies.co.in,navya.karnam@clariontechnologies.co.in,wenhuang07@gmail.com,lou@lofinc.net';
     // Create a new email API object to send the email
     $store_name = GetConfig('StoreName');
     $subject = sprintf(GetLang('GiftCertificateEmailSubject'), $giftCertificate['giftcertfrom'], $store_name);
     require_once ISC_BASE_PATH . "/lib/email.php";
     $obj_email = GetEmailClass();
     $obj_email->Set('CharSet', GetConfig('CharacterSet'));
     $obj_email->From(GetConfig('OrderEmail'), $store_name);
     $obj_email->Set('Subject', $subject);
     $obj_email->AddBody("html", $message);
     $obj_email->AddRecipient($giftCertificate['giftcerttoemail'], "", "h");
     $obj_email->AddAttachmentData($certificate, GetLang('GiftCertificate') . ' #' . $giftCertificate['giftcertid'] . ".html");
     $email_result = $obj_email->Send();
 }
 /**
  * Email a gift certificate to a defined recipient.
  * This function will email a gift certificate to a recipient. It generates the gift certificate from
  * the selected template and attaches it to the gift certificate email.
  */
 public function SendGiftCertificateEmail($giftCertificate)
 {
     if (!$giftCertificate['cgctoemail']) {
         return;
     }
     $mail_body = $this->GenerateCompanyGiftCertificate($giftCertificate, 'mail');
     if (!isset($GLOBALS['ShopPathNormal'])) {
         $GLOBALS['ShopPathNormal'] = $GLOBALS['ShopPath'];
     }
     // Build the email
     $narray = explode('$', $giftCertificate['cgcto']);
     $earray = explode('$', $giftCertificate['cgctoemail']);
     for ($i = 0; $i < count($narray); $i++) {
         if (!preg_match("/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$/", $earray[$i])) {
             continue;
         }
         $GLOBALS['ToName'] = isc_html_escape($narray[$i]);
         $GLOBALS['FromName'] = GetLang('CompanyGiftCertificateFrom');
         $GLOBALS['FromEmail'] = GetConfig('AdminEmail');
         $GLOBALS['Amount'] = FormatPrice($giftCertificate['cgcamount']);
         $GLOBALS['Intro'] = sprintf(GetLang('CompanyGiftCertificateEmailIntro'), $GLOBALS['FromName'], $GLOBALS['FromEmail'], $GLOBALS['Amount'], $GLOBALS['ShopPathNormal'], $GLOBALS['StoreName']);
         $GLOBALS['ISC_LANG']['CompanyGiftCertificateEmailInstructions'] = sprintf(GetLang('CompanyGiftCertificateEmailInstructions'), $GLOBALS['ShopPathNormal']);
         $GLOBALS['ISC_LANG']['GiftCertificateFrom'] = sprintf(GetLang('GiftCertificateFrom'), $GLOBALS['StoreName'], $GLOBALS['FromName']);
         if ($giftCertificate['cgcexpirydate'] != 0) {
             $expiry = CDate($giftCertificate['cgcexpirydate']);
             $GLOBALS['GiftCertificateExpiryInfo'] = sprintf(GetLang('CompanyGiftCertificateEmailExpiry'), $expiry);
         }
         $emailTemplate = FetchEmailTemplateParser();
         $emailTemplate->SetTemplate("company_giftcertificate_email");
         $message = $emailTemplate->ParseTemplate(true);
         //$giftCertificate['giftcerttoemail'] = 'blessen.babu@clariontechnologies.co.in,navya.karnam@clariontechnologies.co.in,wenhuang07@gmail.com,lou@lofinc.net';
         // Create a new email API object to send the email
         $store_name = GetConfig('StoreName');
         $subject = sprintf(GetLang('CompanyGiftCertificateEmailSubject'), $GLOBALS['FromName'], $store_name);
         require_once ISC_BASE_PATH . "/lib/email.php";
         $obj_email = GetEmailClass();
         $obj_email->Set('CharSet', GetConfig('CharacterSet'));
         $obj_email->From(GetConfig('AdminEmail'), $store_name);
         $obj_email->Set('Subject', $subject);
         $obj_email->AddBody("html", $message);
         $obj_email->AddRecipient($earray[$i], "", "h");
         $obj_email->AddAttachmentData($mail_body, GetLang('CompanyGiftCertificate') . ' #' . $giftCertificate['cgcid'] . ".html");
         $updatedCert = array("cgcsended" => 1);
         if (GetConfig('CompanyGiftCertificateExpiry') > 0 and $giftCertificate['cgcexpirydate'] == 0) {
             $expiry = time() + GetConfig('CompanyGiftCertificateExpiry');
             $updatedCert['cgcexpirydate'] = $expiry;
         }
         $tmpres = $GLOBALS['ISC_CLASS_DB']->UpdateQuery("company_gift_certificates", $updatedCert, "cgcid='" . $GLOBALS['ISC_CLASS_DB']->Quote($giftCertificate['cgcid']) . "'");
         $email_result = $obj_email->Send();
     }
 }
Ejemplo n.º 17
0
/**
 *	Send an email notification to a customer when the status of their order changes.
 *
 * @param int The ID of the order to email the invoice for.
 * @return boolean True if successful.
 */
function EmailOnStatusChange($orderId, $status)
{
	// Load the order
	$order = GetOrder($orderId);
	if (!$order) {
		return false;
	}

	// Load the customer we'll be contacting
	if ($order['ordcustid'] > 0) {
		$customer = GetCustomer($order['ordcustid']);
		$GLOBALS['ViewOrderStatusLink'] = '<a href="'.$GLOBALS['ShopPathSSL'].'/orderstatus.php">'.GetLang('ViewOrderStatus').'</a>';
	} else {
		$customer['custconemail'] = $order['ordbillemail'];
		$customer['custconfirstname'] = $order['ordbillfirstname'];
		$GLOBALS['ViewOrderStatusLink'] = '';
	}

	if (empty($customer['custconemail'])) {
		return;
	}

	// All prices in the emailed invoices will be shown in the default currency of the store
	$defaultCurrency = GetDefaultCurrency();

	$statusName = GetOrderStatusById($status);
	$GLOBALS['OrderStatusChangedHi'] = sprintf(GetLang('OrderStatusChangedHi'), isc_html_escape($customer['custconfirstname']));
	$GLOBALS['OrderNumberStatusChangedTo'] = sprintf(GetLang('OrderNumberStatusChangedTo'), $order['orderid'], $statusName);
	$GLOBALS['OrderTotal'] = FormatPrice($order['total_inc_tax'], false, true, false, $defaultCurrency, true);
	$GLOBALS['DatePlaced'] = CDate($order['orddate']);

	if ($order['orderpaymentmethod'] === 'giftcertificate') {
		$GLOBALS['PaymentMethod'] = GetLang('PaymentGiftCertificate');
	}
	else if ($order['orderpaymentmethod'] === 'storecredit') {
		$GLOBALS['PaymentMethod'] = GetLang('PaymentStoreCredit');
	}
	else {
		$GLOBALS['PaymentMethod'] = $order['orderpaymentmethod'];
	}

	$query = "
		SELECT COUNT(*)
		FROM [|PREFIX|]order_products
		WHERE ordprodtype='digital'
		AND orderorderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderId)."'
	";

	$numDigitalProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);

	$emailTemplate = FetchEmailTemplateParser();

	$GLOBALS['SNIPPETS']['CartItems'] = "";

	if (OrderIsComplete($status) && $numDigitalProducts > 0) {
		$query = "
			SELECT *
			FROM [|PREFIX|]order_products op INNER JOIN [|PREFIX|]products p ON (op.ordprodid = p.productid)
			WHERE ordprodtype='digital'
			AND orderorderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderId)."'
		";
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
		while ($product_row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$GLOBALS['ProductOptions'] = '';
			$GLOBALS['ProductQuantity'] = $product_row['ordprodqty'];
			$GLOBALS['ProductName'] = isc_html_escape($product_row['ordprodname']);

			$GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');
			$DownloadItemEncrypted = $GLOBALS['ISC_CLASS_ACCOUNT']->EncryptDownloadKey($product_row['orderprodid'], $product_row['ordprodid'], $orderId, $order['ordtoken']);
			$GLOBALS['DownloadsLink'] = $GLOBALS['ShopPathSSL'].'/account.php?action=download_item&amp;data='.$DownloadItemEncrypted;

			$GLOBALS['SNIPPETS']['CartItems'] .= $emailTemplate->GetSnippet("StatusCompleteDownloadItem");
		}
	}

	$GLOBALS['SNIPPETS']['OrderTrackingLink'] = "";

	$shipments = $GLOBALS['ISC_CLASS_DB']->Query("
		SELECT shipmentid, shipdate, shiptrackno, shipping_module, shipmethod, shipcomments
		FROM [|PREFIX|]shipments
		WHERE shiporderid = " . (int)$orderId . "
		ORDER BY shipdate, shipmentid
	");

	$GLOBALS['TrackingLinkList'] = '';

	while($shipment = $GLOBALS['ISC_CLASS_DB']->Fetch($shipments)) {
		if (!$shipment['shiptrackno']) {
			continue;
		}

		GetModuleById('shipping', /** @var ISC_SHIPPING */$module, $shipment['shipping_module']);

		if ($module) {
			$link = $module->GetTrackingLink($shipment['shiptrackno']);
			if ($link) {
				$link = '<a href="' . isc_html_escape($link) . '" target="_blank">' . $shipment['shiptrackno'] . '</a>';
			} else {
				$link = $shipment['shiptrackno'];
			}
		} else {
			$link = $shipment['shiptrackno'];
		}

		if($shipment['shipmethod']) {
			$link .= ' (' . $shipment['shipmethod'] . ')';
		}

		if ($link) {
			$GLOBALS['TrackingLinkList'] .= '<li>' . $link . '</li>';
		}
	}

	if (empty($GLOBALS['TrackingLinkList'])) {
		$GLOBALS['TrackingLinkList'] = GetLang('NoTrackingNumbersYet');
	} else {
		$GLOBALS['TrackingLinkList'] = '<ul>' . $GLOBALS['TrackingLinkList'] . '</ul>';
	}

	// Set up tracking numbers for orders. Whilst we don't have tracking numbers
	// on orders any longer, this code is being kept for legacy reasons where
	// orders may already have a tracking number saved. To be removed in a future
	// version.
	if (!empty($order['ordtrackingno'])) {
		$GLOBALS['HideTrackingText'] = "";
		$GLOBALS['OrderTrackingNo'] = isc_html_escape($order['ordtrackingno']);

		// Let's instantiate an object for the shipper
		$shipper_object = false;
		if ($order['ordershipmodule'] != "" && GetModuleById('shipping', $shipper_object, $order['ordershipmodule'])) {
			// Does it have a link to track the order?
			if ($shipper_object->GetTrackingLink() != "") {
				// Show the tracking link
				$GLOBALS['TrackURL'] = $shipper_object->GetTrackingLink($order['ordtrackingno']);
				$GLOBALS['SNIPPETS']['OrderTrackingLink'] = $emailTemplate->GetSnippet("OrderTrackingLink");
			}
		}
	}

	if (empty($GLOBALS['SNIPPETS']['CartItems'])) {
		$emailTemplate->SetTemplate("order_status_email");
	} else {
		$emailTemplate->SetTemplate("order_status_downloads_email");
	}
	$message = $emailTemplate->ParseTemplate(true);

	// Create a new email API object to send the email
	$store_name = GetConfig('StoreName');
	$subject = GetLang('OrderStatusChangedSubject');

	require_once(ISC_BASE_PATH . "/lib/email.php");
	$obj_email = GetEmailClass();
	$obj_email->Set('CharSet', GetConfig('CharacterSet'));
	$obj_email->From(GetConfig('OrderEmail'), $store_name);
	$obj_email->Set('Subject', $subject);
	$obj_email->AddBody("html", $message);
	$obj_email->AddRecipient($customer['custconemail'], '', "h");
	$email_result = $obj_email->Send();

	if ($email_result['success']) {
		return true;
	}
	else {
		return false;
	}
}
Ejemplo n.º 18
0
 /**
  * Actually commit a vendor payment to the database.
  *
  * @param array An array of details about the vendor payment.
  * @return int The ID of the new vendor payment that was just created.
  */
 private function CommitVendorPayment($data)
 {
     if (!isset($data['paymentdeducted'])) {
         $data['paymentdeducted'] = 0;
     }
     if (!isset($data['paymentcomments'])) {
         $data['paymentcomments'] = '';
     }
     $paymentDetails = $this->CalculateOutstandingVendorBalance($data['paymentvendorid']);
     $balanceForward = number_format($paymentDetails['balanceForward'], GetConfig('DecimalPlaces'));
     $totalOrders = number_format($paymentDetails['totalOrders'], GetConfig('DecimalPlaces'));
     $profitMargin = number_format($paymentDetails['profitMargin'], GetConfig('DecimalPlaces'));
     $forwardBalance = $balanceForward + $totalOrders - $profitMargin;
     if ($data['paymentdeducted']) {
         $forwardBalance -= $data['paymentamount'];
     }
     $data['paymentamount'] = CNumeric($data['paymentamount']);
     $newPayment = array('paymentfrom' => $data['paymentfrom'], 'paymentto' => $data['paymentto'], 'paymentvendorid' => $data['paymentvendorid'], 'paymentamount' => $data['paymentamount'], 'paymentforwardbalance' => $forwardBalance, 'paymentmethod' => $data['paymentmethod'], 'paymentdate' => time(), 'paymentdeducted' => $data['paymentdeducted'], 'paymentcomments' => $data['paymentcomments']);
     $paymentId = $GLOBALS['ISC_CLASS_DB']->InsertQuery('vendor_payments', $newPayment);
     if (isset($data['notifyvendor'])) {
         $query = "\n\t\t\t\tSELECT vendorname, vendoremail\n\t\t\t\tFROM [|PREFIX|]vendors\n\t\t\t\tWHERE vendorid='" . (int) $data['paymentvendorid'] . "'\n\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $vendor = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         $emailTemplate = FetchEmailTemplateParser();
         $GLOBALS['VendorName'] = isc_html_escape($vendor['vendorname']);
         $GLOBALS['VendorPaymentEmail1'] = sprintf(GetLang('VendorPaymentEmail1'), isc_html_escape(GetConfig('StoreName')), CDate($data['paymentfrom']), CDate($data['paymentto']));
         $GLOBALS['SalesFrom'] = CDate($data['paymentfrom']);
         $GLOBALS['SalesTo'] = CDate($data['paymentto']);
         $GLOBALS['OrderTotal'] = FormatPrice($paymentDetails['totalOrders']);
         $GLOBALS['PaymentAmount'] = FormatPrice($data['paymentamount']);
         $GLOBALS['PaymentMethod'] = isc_html_escape($data['paymentmethod']);
         if ($data['paymentcomments']) {
             $GLOBALS['Comments'] = '<strong>' . GetLang('Comments') . ':</strong><br />' . isc_html_escape($data['paymentcomments']);
         }
         $GLOBALS['AccountBalance'] = FormatPrice($forwardBalance);
         $emailTemplate->SetTemplate("vendor_payment");
         $message = $emailTemplate->ParseTemplate(true);
         // Create a new email API object to send the email
         $storeName = GetConfig('StoreName');
         $subject = sprintf(GetLang('VendorPaymentEmailSubject'), $storeName);
         require_once ISC_BASE_PATH . "/lib/email.php";
         $objEmail = GetEmailClass();
         $objEmail->Set('CharSet', GetConfig('CharacterSet'));
         $objEmail->From(GetConfig('AdminEmail'), $storeName);
         $objEmail->Set('Subject', $subject);
         $objEmail->AddBody("html", $message);
         $objEmail->AddRecipient($vendor['vendoremail'], '', "h");
         $objEmail->Send();
     }
     if (!$paymentId) {
         return false;
     }
     return $paymentId;
 }
Ejemplo n.º 19
0
 /**
  * Test the SMTP settings from the settings page.
  *
  */
 private function TestSMTPSettings()
 {
     $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->LoadLangFile('settings');
     $subject = sprintf(GetLang('TestSendingSubject'), GetConfig('StoreName'));
     $text = sprintf(GetLang('TestSendingEmail'), GetConfig('StoreName'));
     if (!isset($_POST['AdminEmail'])) {
         $tags[] = $this->MakeXMLTag('status', 0);
         $tags[] = $this->MakeXMLTag('message', GetLang('EnterAdminEmail'));
         $this->SendXMLHeader();
         $this->SendXMLResponse($tags);
         die;
     } else {
         $preview_email = $_POST['AdminEmail'];
     }
     require_once ISC_BASE_PATH . "/lib/email.php";
     $email_api = GetEmailClass();
     $email_api->Set('SMTPServer', $_POST['MailSMTPServer']);
     if (isset($_POST['MailSMTPUsername']) && !empty($_POST['MailSMTPUsername'])) {
         $email_api->Set('SMTPUsername', $_POST['MailSMTPUsername']);
     }
     if (isset($_POST['MailSMTPPassword']) && !empty($_POST['MailSMTPPassword'])) {
         $email_api->Set('SMTPPassword', $_POST['MailSMTPPassword']);
     }
     if (isset($_POST['MailSMTPPort']) && !empty($_POST['MailSMTPPort'])) {
         $email_api->Set('SMTPPort', $_POST['MailSMTPPort']);
     }
     $email_api->Set('Subject', $subject);
     $email_api->Set('FromAddress', $preview_email);
     $email_api->Set('ReplyTo', $preview_email);
     $email_api->Set('BounceAddress', $preview_email);
     $email_api->AddBody('text', $text);
     $email_api->AddRecipient($preview_email, '', 't');
     $send_result = $email_api->Send();
     if (isset($send_result['success']) && $send_result['success'] > 0) {
         $tags[] = $this->MakeXMLTag('status', 1);
         $tags[] = $this->MakeXMLTag('message', sprintf(GetLang('TestEmailSent'), $_POST['AdminEmail']));
     } else {
         $failure = array_shift($send_result['fail']);
         $msg = sprintf(GetLang('TestEmailNotSent'), $preview_email, $failure[1]);
         $tags[] = $this->MakeXMLTag('status', 1);
         $tags[] = $this->MakeXMLTag('message', $msg);
     }
     $this->SendXMLHeader();
     $this->SendXMLResponse($tags);
     die;
 }
Ejemplo n.º 20
0
	/**
	 * Build the contents for the order confirmation page. This function sets up everything to be used by
	 * the order confirmation on the express checkout page as well as the ConfirmOrder page when using a
	 * multi step checkout.
	 */
	public function BuildOrderConfirmation()
	{
		$GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');
		if(!GetConfig('ShowMailingListInvite')) {
			$GLOBALS['HideMailingListInvite'] = 'none';
		}

		// Do we need to show the special offers & discounts checkbox and should they
		// either of the newsletter checkboxes be ticked by default?
		if (GetConfig('MailAutomaticallyTickNewsletterBox')) {
			$GLOBALS['NewsletterBoxIsTicked'] = 'checked="checked"';
		}

		if (ISC_EMAILINTEGRATION::doOrderAddRulesExist()) {
			if (GetConfig('MailAutomaticallyTickOrderBox')) {
				$GLOBALS['OrderBoxIsTicked'] = 'checked="checked"';
			}
		}
		else {
			$GLOBALS['HideOrderCheckBox'] = "none";
		}

		if(isset($_REQUEST['ordercomments'])) {
			$GLOBALS['OrderComments'] = $_REQUEST['ordercomments'];
		}

		// Now we check if we have an incoming coupon or gift certificate code to apply
		if (isset($_REQUEST['couponcode']) && $_REQUEST['couponcode'] != '') {
			$code = trim($_REQUEST['couponcode']);

			// Were we passed a gift certificate code?
			if (self::isCertificateCode($code)) {
				try {
					$this->getQuote()->applyGiftCertificate($code);

					// If successful show a message
					$GLOBALS['CheckoutSuccessMsg'] = GetLang('GiftCertificateAppliedToCart');
				}
				catch(ISC_QUOTE_EXCEPTION $e) {
					$GLOBALS['CheckoutErrorMsg'] = $e->getMessage();
				}
			}
			// Otherwise, it must be a coupon code
			else {
				try {
					$this->getQuote()->applyCoupon($code);

					// Coupon code applied successfully
					$GLOBALS['CheckoutSuccessMsg'] = GetLang('CouponAppliedToCart');
				}
				catch(ISC_QUOTE_EXCEPTION $e) {
					$GLOBALS['CheckoutErrorMsg'] = $e->getMessage();
				}
			}
		}

		$GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');

		// Determine what we'll be showing for the redeem gift certificate/coupon code box
		if (gzte11(ISC_LARGEPRINT)) {
			$GLOBALS['RedeemTitle'] = GetLang('RedeemGiftCertificateOrCoupon');
			$GLOBALS['RedeemIntro'] = GetLang('RedeemGiftCertificateorCouponIntro');
		}
		else {
			$GLOBALS['RedeemTitle'] = GetLang('RedeemCouponCode');
			$GLOBALS['RedeemIntro'] = GetLang('RedeemCouponCodeIntro');
		}

		$GLOBALS['HideCheckoutError'] = "none";
		$GLOBALS['HidePaymentOptions'] = "";
		$GLOBALS['HideUseCoupon'] = '';
		$checkoutProviders = array();

		// if the provider list html is set in session then use it as the payment provider options.
		// it's normally set in payment modules when it's required.
		if(isset($_SESSION['CHECKOUT']['ProviderListHTML'])) {
			$GLOBALS['HidePaymentProviderList'] = "";
			$GLOBALS['HidePaymentOptions'] = "";
			$GLOBALS['PaymentProviders'] = $_SESSION['CHECKOUT']['ProviderListHTML'];
			$GLOBALS['StoreCreditPaymentProviders'] = $_SESSION['CHECKOUT']['ProviderListHTML'];
			$GLOBALS['CheckoutWith'] = "";
		} else {
			// Get a list of checkout providers
			$checkoutProviders = GetCheckoutModulesThatCustomerHasAccessTo(true);


			// If no checkout providers are set up, send an email to the store owner and show an error message
			if (empty($checkoutProviders)) {
				$GLOBALS['HideConfirmOrderPage'] = "none";
				$GLOBALS['HideCheckoutError'] = '';
				$GLOBALS['HideTopPaymentButton'] = "none";
				$GLOBALS['HidePaymentProviderList'] = "none";
				$GLOBALS['CheckoutErrorMsg'] = GetLang('NoCheckoutProviders');
				$GLOBALS['NoCheckoutProvidersError'] = sprintf(GetLang("NoCheckoutProvidersErrorLong"), $GLOBALS['ShopPath']);

				$GLOBALS['EmailHeader'] = GetLang("NoCheckoutProvidersSubject");
				$GLOBALS['EmailMessage'] = sprintf(GetLang("NoCheckoutProvidersErrorLong"), $GLOBALS['ShopPath']);

				$emailTemplate = FetchEmailTemplateParser();
				$emailTemplate->SetTemplate("general_email");
				$message = $emailTemplate->ParseTemplate(true);

				require_once(ISC_BASE_PATH . "/lib/email.php");
				$obj_email = GetEmailClass();
				$obj_email->Set('CharSet', GetConfig('CharacterSet'));
				$obj_email->From(GetConfig('OrderEmail'), GetConfig('StoreName'));
				$obj_email->Set("Subject", GetLang("NoCheckoutProvidersSubject"));
				$obj_email->AddBody("html", $message);
				$obj_email->AddRecipient(GetConfig('AdminEmail'), "", "h");
				$email_result = $obj_email->Send();
			}

			// We have more than one payment provider, hide the top button and build a list
			else if (count($checkoutProviders) > 1) {
				$GLOBALS['HideTopPaymentButton'] = "none";
				$GLOBALS['HideCheckoutError'] = "none";
			}

			// There's only one payment provider - hide the list
			else {
				$GLOBALS['HidePaymentProviderList'] = "none";
				$GLOBALS['HideCheckoutError'] = "none";
				$GLOBALS['HidePaymentOptions'] = "none";
				list(,$provider) = each($checkoutProviders);
				if(method_exists($provider['object'], 'ShowPaymentForm') && !isset($_SESSION['CHECKOUT']['ProviderListHTML'])) {
					$GLOBALS['ExpressCheckoutLoadPaymentForm'] = 'ExpressCheckout.ShowSingleMethodPaymentForm();';
				}
				if ($provider['object']->GetPaymentType() == PAYMENT_PROVIDER_OFFLINE) {
					$GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton();";
				}
				$GLOBALS['CheckoutWith'] = $provider['object']->GetDisplayName();
			}

			// Build the list of payment provider options
			$GLOBALS['PaymentProviders'] = $GLOBALS['StoreCreditPaymentProviders'] =  "";
			foreach ($checkoutProviders as $provider) {
				$GLOBALS['ProviderChecked'] = '';
				if(count($checkoutProviders) == 1) {
					$GLOBALS['ProviderChecked'] = 'checked="checked"';
				}
				$GLOBALS['ProviderId'] = $provider['object']->GetId();
				$GLOBALS['ProviderName'] = isc_html_escape($provider['object']->GetDisplayName());
				$GLOBALS['ProviderType'] = $provider['object']->GetPaymentType("text");
				if(method_exists($provider['object'], 'ShowPaymentForm')) {
					$GLOBALS['ProviderPaymentFormClass'] = 'ProviderHasPaymentForm';
				}
				else {
					$GLOBALS['ProviderPaymentFormClass'] = '';
				}
				$GLOBALS['PaymentFieldPrefix'] = '';
				$GLOBALS['PaymentProviders'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutProviderOption");
				$GLOBALS['PaymentFieldPrefix'] = 'credit_';
				$GLOBALS['StoreCreditPaymentProviders'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutProviderOption");
			}

		}

		// Are we coming back to this page for a particular reason?
		if (isset($_SESSION['REDIRECT_TO_CONFIRMATION_MSG'])) {
			$GLOBALS['HideCheckoutError'] = '';
			$GLOBALS['CheckoutErrorMsg'] = $_SESSION['REDIRECT_TO_CONFIRMATION_MSG'];
			unset($_SESSION['REDIRECT_TO_CONFIRMATION_MSG']);
		}

		$displayIncludingTax = false;
		if(getConfig('taxDefaultTaxDisplayCart') != TAX_PRICES_DISPLAY_EXCLUSIVE) {
			$displayIncludingTax = true;
		}

		$items = $this->getQuote()->getItems();

		// Start building the summary of all of the items in the order
		$GLOBALS['SNIPPETS']['CartItems'] = '';
		foreach ($items as $item) {
			$GLOBALS['ProductQuantity'] = $item->getQuantity();

			$price = $item->getPrice($displayIncludingTax);
			$total = $item->getTotal($displayIncludingTax);
			$GLOBALS['ProductPrice'] = currencyConvertFormatPrice($price);
			$GLOBALS['ProductTotal'] = currencyConvertFormatPrice($total);

			if($item instanceof ISC_QUOTE_ITEM_GIFTCERTIFICATE) {
				$GLOBALS['GiftCertificateName'] = isc_html_escape($item->getName());
				$GLOBALS['GiftCertificateTo'] = isc_html_escape($item->getRecipientName());
				$GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutCartItemGiftCertificate");
				continue;
			}

			$GLOBALS['ProductAvailability'] = $item->getAvailability();
			$GLOBALS['ItemId'] = $item->getProductId();

			// Is this product a variation?
			$GLOBALS['ProductOptions'] = '';
			$options = $item->getVariationOptions();
			if(!empty($options)) {
				$GLOBALS['ProductOptions'] .= "<br /><small>(";
				$comma = '';
				foreach($options as $name => $value) {
					if(!trim($name) || !trim($value)) {
						continue;
					}
					$GLOBALS['ProductOptions'] .= $comma.isc_html_escape($name).": ".isc_html_escape($value);
					$comma = ', ';
				}
				$GLOBALS['ProductOptions'] .= ")</small>";
			}
			$GLOBALS['EventDate'] = '';
			$eventDate = $item->getEventDate(true);
			if(!empty($eventDate)) {
				$GLOBALS['EventDate'] = '
					<div style="font-style: italic; font-size:10px; color:gray">(' .
						$item->getEventName() . ': ' . isc_date('M jS Y', $eventDate) .
					')</div>';
			}

			$GLOBALS['HideGiftWrapping'] = 'display: none';
			$GLOBALS['GiftWrappingName'] = '';
			$GLOBALS['GiftMessagePreview'] = '';
			$GLOBALS['HideGiftMessagePreview'] = 'display: none';

			$wrapping = $item->getGiftWrapping();
			if($wrapping !== false) {
				$GLOBALS['HideGiftWrapping'] = '';
				$GLOBALS['GiftWrappingName'] = isc_html_escape($wrapping['wrapname']);
				if(!empty($wrapping['wrapmessage'])) {
					if(isc_strlen($wrapping['wrapmessage']) > 30) {
						$wrapping['wrapmessage'] = substr($wrapping['wrapmessage'], 0, 27).'...';
					}
					$GLOBALS['GiftMessagePreview'] = isc_html_escape($wrapping['wrapmessage']);
					$GLOBALS['HideGiftMessagePreview'] = '';
				}
			}

			//create configurable product fields on order confirmation page with the data posted from add to cart page
			$GLOBALS['CartProductFields'] = '';
			$configuration = $item->getConfiguration();
			if (!empty($configuration)) {
				require_once ISC_BASE_PATH.'/includes/display/CartContent.php';
				ISC_CARTCONTENT_PANEL::GetProductFieldDetails($configuration, $item->getId());
			}

			$GLOBALS['ProductName'] = isc_html_escape($item->getName());
			$GLOBALS['ProductImage'] = imageThumb($item->getThumbnail(), prodLink($item->getName()));

			$GLOBALS['HideExpectedReleaseDate'] = 'display: none;';
			if($item->isPreOrder()) {
				$GLOBALS['ProductExpectedReleaseDate'] = $item->getPreOrderMessage();
				$GLOBALS['HideExpectedReleaseDate'] = '';
			}

			$GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutCartItem");
		}

		// Do we have a shipping price to show?
		if(!$this->getQuote()->isDigital()) {
			$shippingAddresses = $this->getQuote()->getShippingAddresses();
			$numShippingAddresses = count($shippingAddresses);
			if($numShippingAddresses == 1) {
				$shippingAddress = $this->getQuote()->getShippingAddress();
				$GLOBALS['ShippingAddress'] = $GLOBALS['ISC_CLASS_ACCOUNT']->FormatShippingAddress($shippingAddress->getAsArray());
			}
			else {
				$GLOBALS['ShippingAddress'] = '<em>(Order will be shipped to multiple addresses)</em>';
			}

			// Show the shipping details
			$GLOBALS['HideShippingDetails'] = '';
		}
		// This is a digital order - no shipping applies
		else {
			$GLOBALS['HideShippingDetails'] = 'display: none';
			$GLOBALS['HideShoppingCartShippingCost'] = 'none';
			$GLOBALS['ShippingAddress'] = GetLang('NotRequiredForDigitalDownloads');
			$GLOBALS['ShippingMethod'] = GetLang('ShippingImmediateDownload');
		}

		$billingAddress = $this->getQuote()->getBillingAddress();
		$GLOBALS['BillingAddress'] = getClass('ISC_ACCOUNT')
			->formatShippingAddress($billingAddress->getAsArray());

		$totalRows = self::getQuoteTotalRows($this->getQuote());
		$templateTotalRows = '';
		foreach($totalRows as $id => $totalRow) {
			$GLOBALS['ISC_CLASS_TEMPLATE']->assign('label', $totalRow['label']);
			$GLOBALS['ISC_CLASS_TEMPLATE']->assign('classNameAppend', ucfirst($id));
			$value = currencyConvertFormatPrice($totalRow['value']);
			$GLOBALS['ISC_CLASS_TEMPLATE']->assign('value', $value);
			$templateTotalRows .= $GLOBALS['ISC_CLASS_TEMPLATE']->getSnippet('CheckoutCartTotal');
		}
		$GLOBALS['ISC_CLASS_TEMPLATE']->assign('totals', $templateTotalRows);

		$grandTotal = $this->getQuote()->getGrandTotal();
		$GLOBALS['GrandTotal'] = formatPrice($grandTotal);
		if($grandTotal == 0) {
			$GLOBALS['HidePaymentOptions'] = "none";
			$GLOBALS['HideUseCoupon'] = 'none';
			$GLOBALS['HidePaymentProviderList'] = "none";
			$GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton(); ExpressCheckout.UncheckPaymentProvider();";
		}

		// Does the customer have any store credit they can use?
		$GLOBALS['HideUseStoreCredit'] = "none";
		$GLOBALS['HideRemainingStoreCredit'] = "none";
		$customer = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerDataByToken();
		if ($customer['custstorecredit'] > 0) {
			$GLOBALS['HidePaymentOptions'] = "";
			$GLOBALS['StoreCredit'] = CurrencyConvertFormatPrice($customer['custstorecredit']);
			$GLOBALS['HideUseStoreCredit'] = "";
			$GLOBALS['HidePaymentProviderList'] = "none";
			// The customer has enough store credit to pay for the entirity of this order
			if ($customer['custstorecredit'] >= $grandTotal) {
				$GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton();";
				$GLOBALS['HideLimitedCreditWarning'] = "none";
				$GLOBALS['HideLimitedCreditPaymentOption'] = "none";
				$GLOBALS['HideCreditPaymentMethods'] = "none";
				$GLOBALS['RemainingCredit'] = $customer['custstorecredit'] - $grandTotal;
				if ($GLOBALS['RemainingCredit'] > 0) {
					$GLOBALS['HideRemainingStoreCredit'] = '';
					$GLOBALS['RemainingCredit'] = CurrencyConvertFormatPrice($GLOBALS['RemainingCredit']);
				}
			}
			// Customer doesn't have enough store credit to pay for the order
			else {
				$GLOBALS['Remaining'] = CurrencyConvertFormatPrice($grandTotal-$customer['custstorecredit']);

				if(count($checkoutProviders) == 1) {
					$GLOBALS['CheckoutStoreCreditWarning'] = sprintf(GetLang('CheckoutStoreCreditWarning2'), $GLOBALS['Remaining'], $GLOBALS['CheckoutWith']);
					$GLOBALS['HideLimitedCreditPaymentOption'] = "none";
				}
				else {
					$GLOBALS['CheckoutStoreCreditWarning'] = GetLang('CheckoutStoreCreditWarning');
				}
				$GLOBALS['ISC_LANG']['CreditPaymentMethod'] = sprintf(GetLang('CreditPaymentMethod'), $GLOBALS['Remaining']);
			}

			if (count($checkoutProviders) > 1) {
				$GLOBALS['CreditAlt'] = GetLang('CheckoutCreditAlt');
			}
			else if (count($checkoutProviders) <= 1 && isset($GLOBALS['CheckoutWith'])) {
				$GLOBALS['CreditAlt'] = sprintf(GetLang('CheckoutCreditAltOneMethod'), $GLOBALS['CheckoutWith']);
			}
			else {
				if ($customer['custstorecredit'] >= $grandTotal) {
					$GLOBALS['HideCreditAltOptionList'] = "none";
					$GLOBALS['HideConfirmOrderPage'] = "";
					$GLOBALS['HideTopPaymentButton'] = "none";
					$GLOBALS['HideCheckoutError'] = "none";
					$GLOBALS['CheckoutErrorMsg'] = '';
				}
			}
		}

		// Customer has hit this page before. Delete the existing pending order
		// The reason we do a delete is if they're hitting this page again, something
		// has changed with their order or something has become invalid with it along the way.
		if (isset($_COOKIE['SHOP_ORDER_TOKEN']) && IsValidPendingOrderToken($_COOKIE['SHOP_ORDER_TOKEN'])) {
			$query = "
				SELECT orderid
				FROM [|PREFIX|]orders
				WHERE ordtoken='".$GLOBALS['ISC_CLASS_DB']->Quote($_COOKIE['SHOP_ORDER_TOKEN'])."' AND ordstatus=0
			";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			while($order = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$entity = new ISC_ENTITY_ORDER();
				/** @todo ISC-1141 check to see if this needs changing to ->purge() */
				/** @todo ISC-860 this is relying on another bugfix, I'm leaving this as ->delete() for now so that orders remain in the db somewhere at least -gwilym */
				if ($entity->delete($order['orderid'], true)) {
					$GLOBALS['ISC_CLASS_LOG']->LogSystemNotice('general', GetLang('OrderDeletedAutomatically', array('order' => $order['orderid'])));
				}
			}
		}

		// Are we showing an error message?
		if (isset($GLOBALS['CheckoutErrorMsg']) && $GLOBALS['CheckoutErrorMsg'] != '') {
			$GLOBALS['HideCheckoutError'] = '';
		}
		else {
			$GLOBALS['HideCheckoutError'] = "none";
		}

		// Is there a success message to show?
		if (isset($GLOBALS['CheckoutSuccessMsg']) && $GLOBALS['CheckoutSuccessMsg'] != '') {
			$GLOBALS['HideCheckoutSuccess'] = '';
		}
		else {
			$GLOBALS['HideCheckoutSuccess'] = "none";
		}

		if(GetConfig('EnableOrderComments') == 1) {
			$GLOBALS['HideOrderComments'] = "";
		} else {
			$GLOBALS['HideOrderComments'] = "none";
		}

		if(GetConfig('EnableOrderTermsAndConditions') == 1) {

			$GLOBALS['HideOrderTermsAndConditions'] = "";

			if(GetConfig('OrderTermsAndConditionsType') == "link") {
				$GLOBALS['AgreeTermsAndConditions'] = GetLang('YesIAgree');

				$GLOBALS['TermsAndConditionsLink'] = "<a href='".GetConfig('OrderTermsAndConditionsLink')."' target='_BLANK'>".strtolower(GetLang('TermsAndConditions'))."</a>.";

				$GLOBALS['HideTermsAndConditionsTextarea'] = "display:none;";

			} else {
				$GLOBALS['HideTermsAndConditionsTextarea']= '';
				$GLOBALS['OrderTermsAndConditions'] = GetConfig('OrderTermsAndConditions');
				$GLOBALS['AgreeTermsAndConditions'] = GetLang('AgreeTermsAndConditions');
				$GLOBALS['TermsAndConditionsLink'] = '';
			}
		} else {
			$GLOBALS['HideOrderTermsAndConditions'] = "display:none;";
		}

		// BCSIXBETA-372 - mail format preferences removed/disabled for now
		// %%SNIPPET_CheckoutMailFormatPreference%% references also need to be added back into the checkout panels/snippets to re-enable this if needed
//		$GLOBALS['MailFormatPreferenceOptions'] = $this->GenerateMailFormatPreferenceOptions();
//		$GLOBALS['SNIPPETS']['CheckoutMailFormatPreference'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CheckoutMailFormatPreference');
	}
Ejemplo n.º 21
0
 /**
  * Save a new order in the database.
  */
 private function SaveNewOrder()
 {
     if (!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Add_Orders)) {
         $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
         return;
     }
     $message = '';
     if (!$this->ValidateOrder($_POST, $message)) {
         FlashMessage($message, MSG_ERROR);
         $this->AddOrder();
         return;
     }
     $randompassword = $this->generatePassword();
     # Baskaran
     $_POST['custpassword'] = $randompassword;
     $cusemail = $_POST['custconemail'];
     $orderId = $this->CommitOrder($_POST);
     if (!$orderId) {
         $error = $GLOBALS['ISC_CLASS_DB']->GetErrorMsg();
         FlashMessage(GetLang('ProblemSavingOrder') . $error, MSG_ERROR);
         $this->AddOrder();
         return;
     } else {
         /* Password email -- Baskaran */
         $store_name = GetConfig('StoreName');
         $cusfirstname = $GLOBALS['CusFirstname'];
         $GLOBALS['ISC_LANG']['ThanksForRegisteringAtIntro'] = sprintf(GetLang('ThanksForRegisteringAtIntro'), $GLOBALS['StoreName']);
         $subject = "Thanks for Registering at ";
         $ThanksForRegisteringEmailLogin = sprintf("To sign in to your account, please visit <a href='%s'>%s</a> or <a href='%s'>click here</a>.", $GLOBALS['ShopPathSSL'] . "/account.php", $GLOBALS['ShopPathSSL'] . "/account.php", $GLOBALS['ShopPathSSL'] . "/account.php");
         $ThanksForRegisteringEmailHelp = "If you have any questions regarding your account, click 'Reply' in your email client and we'll be only too happy to help.";
         $message = "<html><body style='font-family:Arial; font-size:12px'>\n\t\t\t\t\t\t<div style='padding:0px 20px 20px 20px'>\n\t\t\t\t\t\t    <h2 style='font-size:22px; height:30px; color:#cc6600; border-bottom:dashed 1px gray'>Thanks for Registering at {$store_name}</h2>\n\t\t\n\t\t\t\t\t\t    <p>Hi {$cusfirstname},</p>\n\t\t\n\t\t\t\t\t\t    <p>Thank you for creating your account at {$store_name}. Your account details are as follows:</p>\n\t\t\n\t\t\t\t\t\t    <p>\n\t\t\t\t\t\t\t<strong>Email Address:</strong> {$cusemail}<br />\n\t\t\t\t\t\t\t<strong>Password:</strong> {$randompassword}\n\t\t\t\t\t\t    </p>\n\t\t\n\t\t\t\t\t\t    <p>{$ThanksForRegisteringEmailLogin}</a>\n\t\t\n\t\t\t\t\t\t    <p>{$ThanksForRegisteringEmailHelp}</a>\n\t\t\n\t\t\t\t\t\t    <p>Thanks<br />{$store_name}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t    </body></html>";
         // Create a new email API object to send the email
         require_once ISC_BASE_PATH . "/lib/email.php";
         $obj_email = GetEmailClass();
         $obj_email->Set('CharSet', GetConfig('CharacterSet'));
         $obj_email->From(GetConfig('OrderEmail'), $store_name);
         $obj_email->Set("Subject", $subject . $store_name);
         $obj_email->AddBody("html", $message);
         $obj_email->AddRecipient($cusemail, "", "h");
         $email_result = $obj_email->Send();
         /* Code Ends */
         // Log this action
         $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($orderId);
         if (isset($_REQUEST['saveandpay'])) {
             //echo "Location:".$GLOBALS['ShopPathSSL']."/admin/index.php?ToDo=payOrder&oid=".$orderId;
             //@ob_end_clean();
             $location = $GLOBALS['ShopPathSSL'] . "/admin/index.php?ToDo=payOrder&oid=" . $orderId;
             //header("Location:".$GLOBALS['ShopPathSSL']."/admin/index.php?ToDo=payOrder&oid=".$orderId);
             //die();
         } else {
             if (isset($_REQUEST['addAnother'])) {
                 $location = "index.php?ToDo=confirmOrder&oid={$orderId}&continue=addOrder";
             } else {
                 $location = "index.php?ToDo=confirmOrder&oid={$orderId}&continue=viewOrders";
             }
         }
         FlashMessage(sprintf(GetLang('OrderCreated'), $orderId, $orderId), MSG_SUCCESS, $location);
     }
 }
Ejemplo n.º 22
0
 private function UpdateOfferStatus()
 {
     $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->LoadLangFile('orders');
     if (isset($_REQUEST['o']) && isset($_REQUEST['s'])) {
         $order_id = (int) $_REQUEST['o'];
         $status = (int) $_REQUEST['s'];
         $order = GetOffer($order_id);
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $order['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             echo 0;
             exit;
         }
         #--------------- Baskaran
         $statuscode = '';
         if ($status == '12') {
             $type = "PRIOR_AUTH_CAPTURE";
             $statuscode = $this->PaymentStatus($order_id, $type);
         } else {
             $type = "VOID";
             $statuscode = $this->PaymentStatus($order_id, $type);
         }
         $query = $GLOBALS['ISC_CLASS_DB']->Query("SELECT * from [|PREFIX|]offers where orderid = '{$order_id}'");
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($query);
         $cus_email = $row['ordbillemail'];
         #---------------
         require_once ISC_BASE_PATH . "/lib/email.php";
         $store_name = GetConfig('StoreName');
         if ($statuscode == '1') {
             if (UpdateOfferStatus($order_id, $status)) {
                 if ($status == '12') {
                     $message = "Your Offer has been approved";
                 } else {
                     $message = "Your offer has been denied";
                 }
                 $obj_email = GetEmailClass();
                 $obj_email->Set('CharSet', GetConfig('CharacterSet'));
                 $obj_email->From(GetConfig('OrderEmail'), $store_name);
                 $obj_email->Set("Subject", "Make an Offer");
                 $obj_email->AddBody("html", $message);
                 $obj_email->AddRecipient($cus_email, "", "h");
                 $email_result = $obj_email->Send();
                 echo 1;
             } else {
                 $message = "Your offer has been denied";
                 $obj_email = GetEmailClass();
                 $obj_email->Set('CharSet', GetConfig('CharacterSet'));
                 $obj_email->From(GetConfig('OrderEmail'), $store_name);
                 $obj_email->Set("Subject", "Make an Offer");
                 $obj_email->AddBody("html", $message);
                 $obj_email->AddRecipient($cus_email, "", "h");
                 $email_result = $obj_email->Send();
                 echo 0;
             }
         }
     } else {
         echo 0;
     }
     exit;
 }
Ejemplo n.º 23
0
 public function SendForgotPassEmail()
 {
     if (isset($_POST['username']) && isset($_POST['newpassword'])) {
         $username = $GLOBALS["ISC_CLASS_DB"]->Quote($_POST['username']);
         $newpassword = $GLOBALS["ISC_CLASS_DB"]->Quote($_POST['newpassword']);
         // Is there a user account with this username?
         $query = sprintf("SELECT * FROM [|PREFIX|]users WHERE LOWER(username)='%s'", $GLOBALS['ISC_CLASS_DB']->Quote(isc_strtolower($username)));
         $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
         if ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) {
             // Build the link so they can change their password
             $email = $row['useremail'];
             $link = sprintf("%s/admin/index.php?ToDo=confirmPasswordChange&t=%s&p=%s", $GLOBALS['ShopPath'], md5($row['token']), md5($newpassword));
             $link = str_replace("//", "/", $link);
             $message = sprintf(GetLang("ChangePassEmail"), $link, $link);
             $store_name = GetConfig('StoreName');
             require_once ISC_BASE_PATH . "/lib/email.php";
             $obj_email = GetEmailClass();
             $obj_email->Set('CharSet', GetConfig('CharacterSet'));
             $obj_email->From(GetConfig('OrderEmail'), $store_name);
             $obj_email->Set("Subject", GetLang("ConfirmPasswordChange"));
             $obj_email->AddBody("html", $message);
             $obj_email->AddRecipient($email, "", "h");
             $email_result = $obj_email->Send();
             // If the email was sent ok, show a confirmation message
             if ($email_result['success']) {
                 $GLOBALS['Message'] = sprintf(GetLang("ConfirmPassEmailSent"), isc_html_escape($email));
                 $GLOBALS["ISC_CLASS_TEMPLATE"]->SetTemplate("password.sent");
                 $GLOBALS["ISC_CLASS_TEMPLATE"]->ParseTemplate();
             } else {
                 die(GetLang("NoEmailSystem"));
             }
         } else {
             $this->ForgotPass(true);
         }
     } else {
         $this->ForgotPass();
     }
 }
Ejemplo n.º 24
0
 private function SendRequestByEmail($email)
 {
     //load the template for email, e.g. $email = "*****@*****.**";
     $templateId = 1;
     if (isset($_GET['templateId']) && is_numeric($_GET['templateId'])) {
         $templateId = (int) $_GET['templateId'];
     }
     $message = $this->paserRequestTemplate($templateId, 'email');
     // Create a new email API object to send the email
     $store_name = GetConfig('StoreName');
     //2010-11-11 Ronnie add ,Read the subject from the database of coupons
     $subject = sprintf(GetLang('ReviewRequestEmailSubject'), $store_name);
     if (isset($GLOBALS['COUPON_EMAIL_SUBJECT'])) {
         $subject = $GLOBALS['COUPON_EMAIL_SUBJECT'];
     }
     require_once ISC_BASE_PATH . "/lib/email.php";
     $obj_email = GetEmailClass();
     $obj_email->Set('CharSet', GetConfig('CharacterSet'));
     $obj_email->From(GetConfig('OrderEmail'), $store_name);
     $obj_email->Set('Subject', $subject);
     $obj_email->AddBody("html", $message);
     $obj_email->AddRecipient($email, "", "h");
     //$obj_email->AddAttachmentData($data, $name);
     $email_result = $obj_email->Send();
     //Create New Coupon Ronnie
     //$this->CreateNewCoupon($_REQUEST['orderId'],$GLOBALS['ROW_COUPON_CODE']);
     return true;
 }