Beispiel #1
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;
	}
}
Beispiel #2
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();
			}
		}
Beispiel #3
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;
		}
	}
 /**
  * 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();
 }
Beispiel #5
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();
	}
Beispiel #6
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;
    }
}
 /**
  * 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;
 }
	/**
	* 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();
	}
 /**
  * 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']);
 }
 /**
  * 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();
     }
 }
Beispiel #11
0
		/**
		 * Actually create a customer account in the database.
		 *
		 * @param array An array of details about the customer.
		 * @param boolean True if a welcome email should be sent out to the customer.
		 * @param boolean True if this account is being created invisibily for the customer via the checkout.
		 * @return int The customer ID if successful.
		 */
		public function CreateCustomerAccount($Customer, $Email=true, $checkoutAccount=false)
		{
			$entity = new ISC_ENTITY_CUSTOMER();
			$customerId = $entity->add($Customer);

			if (!isId($customerId)) {
				return;
			}

			// Do we want to email this custome a copy of their registration details?
			if ($Email == true) {
				$emailTemplate = FetchEmailTemplateParser();

				$GLOBALS['FirstName'] = isc_html_escape($Customer['custconfirstname']);
				$GLOBALS['Email'] = isc_html_escape($Customer['custconemail']);
				$GLOBALS['Password'] = isc_html_escape($Customer['custpassword']);

				if($checkoutAccount) {
					$GLOBALS['ISC_LANG']['ThanksForRegisteringAtIntro'] = sprintf(GetLang('CheckoutAccountCreatedIntro'), $GLOBALS['StoreName']);
					$subject = GetLang('CheckoutAccountCreatedSubject');
					$GLOBALS['ISC_LANG']['THanksForRegisteringAt'] = GetLang('CheckoutAccountCreatedSubject');
				}
				else {
					$GLOBALS['ISC_LANG']['ThanksForRegisteringAtIntro'] = sprintf(GetLang('ThanksForRegisteringAtIntro'), $GLOBALS['StoreName']);
					$subject = GetLang('ThanksForRegisteringAt');
				}
				$GLOBALS['ISC_LANG']['ThanksForRegisteringEmailLogin'] = sprintf(GetLang('ThanksForRegisteringEmailLogin'), $GLOBALS['ShopPathSSL']."/account.php", $GLOBALS['ShopPathSSL']."/account.php", $GLOBALS['ShopPathSSL']."/account.php");

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

				// Create a new email API object 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", $subject . $store_name);
				$obj_email->AddBody("html", $message);
				$obj_email->AddRecipient($Customer['custconemail'], "", "h");
				$email_result = $obj_email->Send();
			}

			return $customerId;
		}
Beispiel #12
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();
	}
 public function paserRequestTemplate($templateId, $type = 'preview')
 {
     if ($type == 'email') {
         $this->GetOrderDetail($_REQUEST['o'], "eamil");
     } else {
         $this->GetOrderDetail($_REQUEST['orderId'], "review");
     }
     $showContent = '';
     $requestTemplate = '';
     $query = "select request_script_value,coupon_code from [|PREFIX|]order_review_request where id='" . $templateId . "'";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $coupon_code_hint = "";
         if (!empty($row['coupon_code'])) {
             $coupon_code_hint = GetLang('CouponCodeHint') . $row['coupon_code'];
         }
         //coupon code should not be included in the email
         /*if($type == 'email'){
         			$coupon_code_hint = "";
         		}*/
         $coupon_code_hint = "";
         $order_reviewlink = sprintf("<a href='%s' target='_blank'>%s</a>", $GLOBALS['OrderReviewLink'], GetLang('OrderReviewLinkTitle'));
         $replaceArr = array('<!--ORDER_DATE-->' => $GLOBALS['OrderDate'], '<!--ORDER DATE-->' => $GLOBALS['OrderDate'], '<!--ORDER_DETAILS-->' => $GLOBALS['OrderDetails'], '<!--ORDER_REVIEW_LINK-->' => $order_reviewlink, '<!--ORDER_COUPON_CODE-->' => $coupon_code_hint);
         $requestTemplate = $row['request_script_value'];
         $requestTemplate = str_ireplace("/admin/", "", $requestTemplate);
         $requestTemplate = htmlspecialchars_decode($requestTemplate);
         foreach ($replaceArr as $replaceReg => $replaceText) {
             $requestTemplate = str_replace($replaceReg, $replaceText, $requestTemplate);
         }
     }
     if ($type == 'preview') {
         $showContent = $requestTemplate;
     } else {
         if ($type == 'email') {
             $GLOBALS['RequestDetail'] = $requestTemplate;
             $emailTemplate = FetchEmailTemplateParser();
             $emailTemplate->SetTemplate("order_reviewrequest_email");
             $showContent = $emailTemplate->ParseTemplate(true);
         }
     }
     return $showContent;
 }
Beispiel #14
0
 private function SaveNewOrderMessage()
 {
     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=viewOrders');
         }
         $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("order_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->ViewOrderMessages(GetLang('OrderMessageSentOK'), MSG_SUCCESS);
             } else {
                 $this->ViewOrderMessages(GetLang('OrderMessagesSentEmailFailed'), MSG_ERROR);
             }
         } else {
             $this->ViewOrderMessages(GetLang('OrderMessagesSentFailed'), MSG_ERROR);
         }
     }
 }
Beispiel #15
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');
	}
Beispiel #16
0
 /**
  * Actually create a customer account in the database.
  *
  * @param array An array of details about the customer.
  * @param boolean True if a welcome email should be sent out to the customer.
  * @param boolean True if this account is being created invisibily for the customer via the checkout.
  * @return int The customer ID if successful.
  */
 public function CreateCustomerAccount($Customer, $Email = true, $checkoutAccount = false)
 {
     /**
      * If we are successful then save all the non-private custom fields. Only if we
      * are NOT a single page checkout account
      */
     if (!isset($_SESSION['CHECKOUT']['CREATE_ACCOUNT']) || GetConfig('CheckoutType') !== 'single') {
         $accountFormSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ACCOUNT);
         if (isId($accountFormSessionId)) {
             $Customer['custformsessionid'] = $accountFormSessionId;
         }
         if (isset($Customer['shipping_address'])) {
             $shippingFormSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ADDRESS);
             if (isId($shippingFormSessionId)) {
                 $Customer['shipping_address']['shipformsessionid'] = $shippingFormSessionId;
             }
         }
     }
     $entity = new ISC_ENTITY_CUSTOMER();
     $customerId = $entity->add($Customer);
     if (!isId($customerId)) {
         return;
     }
     // Do we want to email this custome a copy of their registration details?
     if ($Email == true) {
         $emailTemplate = FetchEmailTemplateParser();
         $GLOBALS['FirstName'] = isc_html_escape($Customer['firstname']);
         $GLOBALS['Email'] = isc_html_escape($Customer['email']);
         $GLOBALS['Password'] = isc_html_escape($Customer['password']);
         if ($checkoutAccount) {
             $GLOBALS['ISC_LANG']['ThanksForRegisteringAtIntro'] = sprintf(GetLang('CheckoutAccountCreatedIntro'), $GLOBALS['StoreName']);
             $subject = GetLang('CheckoutAccountCreatedSubject');
             $GLOBALS['ISC_LANG']['THanksForRegisteringAt'] = GetLang('CheckoutAccountCreatedSubject');
         } else {
             $GLOBALS['ISC_LANG']['ThanksForRegisteringAtIntro'] = sprintf(GetLang('ThanksForRegisteringAtIntro'), $GLOBALS['StoreName']);
             $subject = GetLang('ThanksForRegisteringAt');
         }
         $GLOBALS['ISC_LANG']['ThanksForRegisteringEmailLogin'] = sprintf(GetLang('ThanksForRegisteringEmailLogin'), $GLOBALS['ShopPathSSL'] . "/account.php", $GLOBALS['ShopPathSSL'] . "/account.php", $GLOBALS['ShopPathSSL'] . "/account.php");
         $emailTemplate->SetTemplate("createaccount_email");
         $message = $emailTemplate->ParseTemplate(true);
         // Create a new email API object 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", $subject . $store_name);
         $obj_email->AddBody("html", $message);
         $obj_email->AddRecipient($Customer['email'], "", "h");
         $email_result = $obj_email->Send();
     }
     return $customerId;
 }
Beispiel #17
0
 public function paserRequestTemplate($templateId, $type = 'preview')
 {
     //order Id get Ronnie
     $orderId = $_REQUEST['orderId'];
     if ($type == 'email') {
         $orderId = $_REQUEST['o'];
     }
     if ($type == 'email') {
         $this->GetOrderDetail($_REQUEST['o'], "email");
     } else {
         $this->GetOrderDetail($_REQUEST['orderId'], "review");
     }
     $showContent = '';
     $requestTemplate = '';
     $query = "select request_script_value,coupon_code,emailsubject from [|PREFIX|]order_review_request where id='" . $templateId . "'";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     //$GLOBALS['ROW_COUPON_CODE']="";
     if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $coupon_code_hint = "";
         if (!empty($row['coupon_code'])) {
             //Set coupon Code Ronnie
             //$coupon_code_hint = GetLang('CouponCodeHint').$row['coupon_code'];
             $coupon_code_hint = "";
             //GetLang('CouponCodeHint');//.$row['coupon_code'];
             $Seqno = $this->getSeqNoByOrderID($orderId, $row['coupon_code']);
             $coupon_code_hint .= $Seqno;
             //.$GLOBALS['contactEmail'];
             //$GLOBALS['ROW_COUPON_CODE']=$row['coupon_code'];
             //Create New Coupon Ronnie
             //$this->CreateNewCoupon($_REQUEST['orderId'],$GLOBALS['ROW_COUPON_CODE']);
             if ($type == "email") {
                 //Create New Coupon Ronnie
                 $this->CreateNewCoupon($orderId, $row['coupon_code']);
             }
         } else {
             //No coupon No new coupon
             if ($type == "email") {
                 $this->CancelNewCoupon($this->getSeqNoByOrderID($orderId, ''), $orderId);
             }
         }
         //2010-12-06 Ronnie add,direct url
         $row['request_script_value'] = str_ireplace("src=\"", "src=\"" . $GLOBALS['ShopPath'], $row['request_script_value']);
         $GLOBALS['COUPON_EMAIL_SUBJECT'] = $row['emailsubject'];
         //coupon code should not be included in the email
         /*if($type == 'email'){
         			$coupon_code_hint = "";
         		}*/
         //$coupon_code_hint = "";
         //replace Seqno Ronnie
         //$coupon_code_hint.="-".$Seqno;
         //$query = "select * from [|PREFIX|]coupons where couponcode='".$row['coupon_code']."'";
         //$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         //$row1 = $GLOBALS['ISC_CLASS_DB']->fetch($result);
         //$coupon_code_hint.="--".$query."--".count($result)."--".$row1['couponcode'];
         //$this->DeleteNewCoupon($Seqno,$_REQUEST['orderId'],$row['coupon_code']);
         $query2 = "select concat(a.ordbillfirstname,' ',a.ordbilllastname)custname from [|PREFIX|]orders a ";
         $query2 .= "where a.orderid='" . $orderId . "'";
         $result2 = $GLOBALS['ISC_CLASS_DB']->Query($query2);
         if ($row2 = $GLOBALS['ISC_CLASS_DB']->fetch($result2)) {
             $custName = $row2['custname'];
         }
         $order_reviewlink = sprintf("<a href='%s' target='_blank'>%s</a>", $GLOBALS['OrderReviewLink'], GetLang('OrderReviewLinkTitle'));
         $replaceArr = array('<!--ORDER_CUSTOMER-->' => $custName, '<!--ORDER_DATE-->' => $GLOBALS['OrderDate'], '<!--ORDER_DETAILS-->' => $GLOBALS['OrderDetails'], '<!--ORDER_REVIEW_LINK-->' => $order_reviewlink, '<!--ORDER_COUPON_CODE-->' => $coupon_code_hint == "" ? "None" : $coupon_code_hint);
         $requestTemplate = $row['request_script_value'];
         ///return str_replace("ORDER_DATE", "abc", htmlspecialchars_decode($requestTemplate));
         $requestTemplate = str_ireplace("/admin/", "", $requestTemplate);
         $requestTemplate = htmlspecialchars_decode($requestTemplate);
         foreach ($replaceArr as $replaceReg => $replaceText) {
             $requestTemplate = str_replace($replaceReg, $replaceText, $requestTemplate);
         }
     }
     if ($type == 'preview') {
         $showContent = $requestTemplate;
     } else {
         if ($type == 'email') {
             $GLOBALS['RequestDetail'] = $requestTemplate;
             $emailTemplate = FetchEmailTemplateParser();
             $emailTemplate->SetTemplate("order_reviewrequest_email");
             $showContent = $emailTemplate->ParseTemplate(true);
         }
     }
     return $showContent;
 }