コード例 #1
0
ファイル: CartHeader.php プロジェクト: hungnv0789/vhtm
		public function SetPanelSettings()
		{
			$numItems = getCustomerQuote()->getNumItems();
			$ShowCheckoutButton = false;
			if($numItems > 0) {
				foreach (GetAvailableModules('checkout', true, true) as $module) {
					if ($module['object']->disableNonCartCheckoutButtons) {
						$GLOBALS['HideCheckoutButton'] = 'display: none';
						$ShowCheckoutButton = false;
						break;
					}
					if (!method_exists($module['object'], 'GetCheckoutButton')) {
						$ShowCheckoutButton = true;
					}
				}
			}

			$GLOBALS['HideCheckoutButton'] = '';

			if (!$ShowCheckoutButton) {
				$GLOBALS['HideCheckoutButton'] = 'display: none';
			}
			$this->insertOptimizerLinkScript();

		}
コード例 #2
0
ファイル: CartContent.php プロジェクト: hungnv0789/vhtm
	/**
	 * Set the settings to display this panel.
	 */
	public function setPanelSettings()
	{
		$this->quote = getCustomerQuote();

		// Are there any products in the cart?
		if($this->quote->getNumItems() == 0) {
			$GLOBALS['HideShoppingCartGrid'] = "none";
			return;
		}

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

		$GLOBALS['HideShoppingCartEmptyMessage'] = "none";

		$this->generateAdditionalCheckoutButtons();
		$this->generateCartContent();
		$this->setUpShippingAndHandling();
		$this->setUpAppliedGiftCertificates();
		$this->setUpAppliedCouponsList();
		$this->setUpTaxDisplay();
		$this->setUpDiscountAmount();
	}
コード例 #3
0
ファイル: CartStatusMessage.php プロジェクト: hungnv0789/vhtm
	public function setPanelSettings()
	{
		$discountRules = getCustomerQuote()->getAppliedDiscountRules();
		foreach($discountRules as $discountRule) {
			if(!empty($discountRule['banners'])) {
				foreach($discountRule['banners'] as $banner) {
					flashMessage(getLang('DiscountCongratulations').' '.$banner, MSG_INFO);
				}
			}
		}

		$messages = getFlashMessageBoxes();
		if(!$messages) {
			$this->DontDisplay = true;
			return;
		}

		$GLOBALS['CartStatusMessage'] = $messages;
	}
コード例 #4
0
ファイル: class.coupon.php プロジェクト: hungnv0789/vhtm
	/**
	 * Identify same "customer" as someone with the same customer id, or ip address or email address.
	 *
	 * @return array
	 */
	public function getCustomerIdentifiers()
	{
		$ip = getIp();
		$quote = getCustomerQuote();
		$customerid = $quote->getCustomerId();
		$email = $quote->getBillingAddress()->getEmail();
		if ($email == '') {
			$customer = getCustomer($customerid);
			$email = $customer['custconemail'];
		}

		$identifiers = array(
			$ip,
			$customerid,
			$email,
		);

		return $identifiers;
	}
コード例 #5
0
ファイル: class.discount.php プロジェクト: hungnv0789/vhtm
		public function  __construct()
		{
			$eligibleFreeShippingInfo = getCustomerQuote()
				->getEligibleFreeShippingInfo();
			if (!empty ($eligibleFreeShippingInfo)) {

				$pageType = '';
				$message = '';
				if(isset($GLOBALS['ISC_CLASS_INDEX']) && !empty ($eligibleFreeShippingInfo['homepage'])) {
					$pageType = 'homepage';
				}
				else if(isset($GLOBALS['ISC_CLASS_CHECKOUT']) && !empty ($eligibleFreeShippingInfo['checkoutpage'])) {
					$pageType = 'checkoutpage';
				}
				else if(isset($GLOBALS['ISC_CLASS_PRODUCT']) && !empty ($eligibleFreeShippingInfo['productpage'])) {
					$pageType = 'productpage';
				}
				else if(isset($GLOBALS['ISC_CLASS_CART']) && !empty ($eligibleFreeShippingInfo['cartpage'])) {
					$pageType = 'cartpage';
				}
				if (!empty ($pageType)) {
					$maxRandNum = count($eligibleFreeShippingInfo[$pageType]) - 1;
					$randNum = rand(0, $maxRandNum);
					$message = $eligibleFreeShippingInfo[$pageType][$randNum]['message'];

					// we will show the message of the product, if the user can get get
					// get free shipping by buying 1 or more of current viewed product.
					if ($pageType == 'productpage') {
						$currProductId = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId();
						foreach ($eligibleFreeShippingInfo[$pageType] as $freeShippingInfo) {
							if (!empty($freeShippingInfo['productId']) && $freeShippingInfo['productId'] == $currProductId)  {
								$message = $freeShippingInfo['message'];
							}
						}
					}
					// Save the page type globally so we can access it from the template engine
					$GLOBALS['DiscountPageType'] = $pageType;
					$GLOBALS['DiscountMessage'] = sprintf("<div class='SpecificInfoMessage FreeShippingMessage_%s'>%s</div>", $pageType, $message);
				}
			}
		}
コード例 #6
0
	public function SetPanelSettings()
	{
		// this panel should only be shown for guests entering an address
		if(CustomerIsSignedIn()) {
			$this->DontDisplay = true;
			return;
		}

		$formHtml = '';

		// Enter a billing address
		if($GLOBALS['ShippingFormAction'] == 'save_biller') {
			$formFieldType = FORMFIELDS_FORM_BILLING;
			$quoteAddress = getCustomerQuote()->getBillingAddress();

			// load the email address field
			$GLOBALS['ISC_CLASS_FORM']->addFormFieldUsed($GLOBALS['ISC_CLASS_FORM']->getFormField(FORMFIELDS_FORM_ACCOUNT, '1', '', true));

			// load html for email field
			$formHtml .= $GLOBALS['ISC_CLASS_FORM']->loadFormField(FORMFIELDS_FORM_ACCOUNT, '1');

			$GLOBALS['CheckEmail'] = 'true';
		}
		else {
			$formFieldType = FORMFIELDS_FORM_SHIPPING;
			$quoteAddress = getCustomerQuote()->setIsSplitShipping(false)
				->getShippingAddress();
		}

		$addressFormFields = $GLOBALS['ISC_CLASS_FORM']->getFormFields($formFieldType, false);

		// Coming back here from an error, so use the $_POST values
		$savedFormFieldValues = array();
		if(!empty($GLOBALS['ErrorMessage']) && !empty($_POST['FormField'][$formFieldType])) {
			$savedFormFieldValues = $_POST['FormField'][$formFieldType];
		}
		// Use the address already saved in the quote if there is one
		else {
			// An array containing the methods available in $quoteAddress and the form field "private ID"
			$quoteAddressFields = array(
				'EmailAddress' => 'getEmail',
				'FirstName' => 'getFirstName',
				'LastName' => 'getLastName',
				'CompanyName' => 'getCompany',
				'AddressLine1' => 'getAddress1',
				'AddressLine2' => 'getAddress2',
				'City' => 'getCity',
				'Zip' => 'getZip',
				'State' => 'getStateName',
				'Country' => 'getCountryName',
				'Phone' => 'getPhone',
			);
			foreach($addressFormFields as $formFieldId => $formField) {
				$formFieldPrivateId = $formField->record['formfieldprivateid'];
				if(isset($quoteAddressFields[$formFieldPrivateId])) {
					$method = $quoteAddressFields[$formFieldPrivateId];
					$savedFormFieldValues[$formFieldId] = $quoteAddress->$method();
				}
				else {
					$customField = $quoteAddress->getCustomField($formFieldId);
					if($customField !== false) {
						$savedFormFieldValues[$formFieldId] = $customField;
					}
				}
			}
		}

		$countryFieldId = 0;
		$stateFieldId = 0;
		foreach($addressFormFields as $formFieldId => $formField) {
			$formFieldPrivateId = $formField->record['formfieldprivateid'];
			if(isset($savedFormFieldValues[$formFieldId])) {
				$formField->setValue($savedFormFieldValues[$formFieldId]);
			}

			if($formFieldPrivateId == 'Country') {
				$countryFieldId = $formFieldId;
			}
			else if($formFieldPrivateId == 'State') {
				$stateFieldId = $formFieldId;
			}
		}

		if($countryFieldId) {
			$addressFormFields[$countryFieldId]->setOptions(array_values(GetCountryListAsIdValuePairs()));
			if ($addressFormFields[$countryFieldId]->getValue() == '') {
				$addressFormFields[$countryFieldId]->setValue(GetConfig('CompanyCountry'));
			}

			if ($stateFieldId) {
				$addressFormFields[$countryFieldId]->addEventHandler('change', 'FormFieldEvent.SingleSelectPopulateStates', array('countryId' => $countryFieldId, 'stateId' => $stateFieldId));
				$countryId = GetCountryByName($addressFormFields[$countryFieldId]->getValue());
				$stateOptions = GetStateListAsIdValuePairs($countryId);

				if (is_array($stateOptions) && !empty($stateOptions)) {
					$addressFormFields[$stateFieldId]->setOptions($stateOptions);
				}
				else {
					// no states for our country, we need to mark this as not required
					$addressFormFields[$stateFieldId]->setRequired(false);
				}
			}
		}

		foreach($addressFormFields as $formField) {
			if (isc_strtolower($formField->record['formfieldprivateid']) == 'savethisaddress' ||
				isc_strtolower($formField->record['formfieldprivateid']) == 'shiptoaddress') {
					continue;
			}

			$formHtml .= $formField->loadForFrontend();
			$GLOBALS['ISC_CLASS_FORM']->addFormFieldUsed($formField);
		}

		$GLOBALS['ShipCustomFields'] = $formHtml;
		$GLOBALS['AddressFormFieldID'] = $formFieldType;
		$GLOBALS['FormFieldRequiredJS'] = $GLOBALS['ISC_CLASS_FORM']->buildRequiredJS();
	}
コード例 #7
0
ファイル: class.eway.hosted.php プロジェクト: hungnv0789/vhtm
	public function TransferToProvider()
	{
		$currency = GetDefaultCurrency();
		$currencyCode = $currency['currencycode'];

		$orders = $this->GetOrders();
		list(,$order) = each($orders);

		$amount = number_format($this->GetGatewayAmount(), '2');

		$billingDetails = $this->GetBillingDetails();

		$invoiceDescription = '';
		$quote = getCustomerQuote();
		foreach ($quote->getItems() as /** @var ISC_QUOTE_ITEM */$item){
			if ($invoiceDescription) {
				$invoiceDescription .= ", ";
			}

			$invoiceDescription .= $item->getQuantity() . 'x ' . $item->getName();
		}

		$data = array(
			'CustomerID'		=> $this->GetValue('customerid'),
			'UserName'			=> $this->GetValue('username'),
			'Currency'			=> $currencyCode,
			'Amount'			=> $amount,
			'ReturnURL'			=> $GLOBALS['ShopPath'] . '/finishorder.php',
			'CancelURL'			=> $GLOBALS['ShopPath'] . '/finishorder.php',
			'CompanyName'		=> GetConfig('CompanyName'),

			'CustomerFirstName'	=> $billingDetails['ordbillfirstname'],
			'CustomerLastName'	=> $billingDetails['ordbilllastname'],
			'CustomerAddress'	=> $billingDetails['ordbillstreet1'] . ' ' . $billingDetails['ordbillstreet2'],
			'CustomerCity'		=> $billingDetails['ordbillsuburb'],
			'CustomerState'		=> $billingDetails['ordbillstate'],
			'CustomerPostCode'	=> $billingDetails['ordbillzip'],
			'CustomerCountry'	=> $billingDetails['ordbillcountry'],
			'CustomerPhone'		=> $billingDetails['ordbillphone'],
			'CustomerEmail'		=> $billingDetails['ordbillemail'],

			'InvoiceDescription'=> $invoiceDescription,
			'MerchantReference' => $this->GetCombinedOrderId(),
		);

		$ewayUrl = $this->_ewayURL . 'Request?';
		$ewayUrl .= http_build_query($data);

		$response = PostToRemoteFileAndGetResponse($ewayUrl);

		if (empty($response)) {
			$this->logInvalidResponse($response, true);
		}

		try {
			$xml = new SimpleXMLElement($response);
		}
		catch (Exception $ex) {
			$this->logInvalidResponse($response, true);
		}

		if ((string)$xml->Result == 'True') {
			$transferUri = (string)$xml->URI;
			$this->RedirectToProvider($transferUri);
		}
		else {
			$this->logInvalidResponse((string)$xml->Error(), true);
		}
	}
コード例 #8
0
ファイル: class.handler.php プロジェクト: hungnv0789/vhtm
	/**
	 * Revert the session to a previous cart's session
	 *
	 * @param string $cartid The previous session id
	 *
	 * @return boolean true on success
	 **/
	public function LoadCart($cartid)
	{
		// Load the session that the user had when they were checking out
		session_write_close();

		$session = new ISC_SESSION($cartid);

		if (!isset($_SESSION['QUOTE'])) {
			$GLOBALS['ISC_CLASS_LOG']->LogSystemError($this->logtype, sprintf(GetLang('GoogleCheckoutHandlerCantLoadCart'), isc_html_escape($cartid)));
			return false;
		}

		$error = '';

		$this->quote = getCustomerQuote();
		return true;
	}
コード例 #9
0
ファイル: init.php プロジェクト: hungnv0789/vhtm
$GLOBALS['ISC_CLASS_VISITOR'] = GetClass('ISC_VISITOR');

if(isset($GLOBALS['ShowStoreUnavailable'])) {
	$GLOBALS['ErrorMessage'] = GetLang('StoreUnavailable');
	$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("error");
	$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
	exit;
}

// Set the default page title
$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(GetConfig('StoreName'));

// Get the number of items in the cart if any
if(isset($_SESSION['QUOTE'])) {
	$quote = getCustomerQuote();
	$numItems = $quote->getNumItems();
	$items = $quote->getItems();
	foreach($items as $item) {
		if(!$item->getProductId()) {
			continue;
		}

		$GLOBALS['CartQuantity'.$item->getProductId()] = $item->getQuantity();
	}

	if ($numItems == 1) {
		$GLOBALS['CartItems'] = ' ('.GetLang('OneItem').')';
	}
	else if ($numItems > 1) {
		$GLOBALS['CartItems'] = ' ('.GetLang('XItems', array('count' => $numItems)).')';
コード例 #10
0
ファイル: class.checkout.php プロジェクト: hungnv0789/vhtm
	public function getQuote()
	{
		return getCustomerQuote();
	}
コード例 #11
0
ファイル: class.cart.php プロジェクト: hungnv0789/vhtm
	protected function getQuote()
	{
		return getCustomerQuote();
	}
コード例 #12
0
		/**
		 * Set the settings for this panel.
		 */
		public function SetPanelSettings()
		{

			$GLOBALS['HideTabMultiple'] = 'display: none';
			$GLOBALS['ActiveTabSingle'] = 'Active';

			$GLOBALS['SNIPPETS']['ShippingAddressList'] = "";
			$GLOBALS['ShippingAddressRow'] = "";
			$count = 0;

			$GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');


			$numItems = getCustomerQuote()->getNumPhysicalItems();

			// Get a list of all shipping addresses for this customer and out them as radio buttons
			$shipping_addresses = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerShippingAddresses();

			if(empty($shipping_addresses) && isset($GLOBALS['CheckoutShippingIntroNoAddresses'])) {
				$GLOBALS['CheckoutShippingIntro'] = $GLOBALS['CheckoutShippingIntroNoAddresses'];
			}

			$GLOBALS['SplitAddressList'] = '';
			foreach($shipping_addresses as $address) {
				$GLOBALS['ShippingAddressId'] = (int) $address['shipid'];
				$GLOBALS['ShipFullName'] = isc_html_escape($address['shipfirstname'].' '.$address['shiplastname']);

				$GLOBALS['ShipCompany'] = '';
				if($address['shipcompany']) {
					$GLOBALS['ShipCompany'] = isc_html_escape($address['shipcompany']).'<br />';
				}

				$GLOBALS['ShipAddressLine1'] = isc_html_escape($address['shipaddress1']);

				if($address['shipaddress2'] != "") {
					$GLOBALS['ShipAddressLine2'] = isc_html_escape($address['shipaddress2']);
				} else {
					$GLOBALS['ShipAddressLine2'] = '';
				}

				$GLOBALS['ShipSuburb'] = isc_html_escape($address['shipcity']);
				$GLOBALS['ShipState'] = isc_html_escape($address['shipstate']);
				$GLOBALS['ShipZip'] = isc_html_escape($address['shipzip']);
				$GLOBALS['ShipCountry'] = isc_html_escape($address['shipcountry']);

				if($address['shipphone'] != "") {
					$GLOBALS['ShipPhone'] = isc_html_escape(sprintf("%s: %s", GetLang('Phone'), $address['shipphone']));
				}
				else {
					$GLOBALS['ShipPhone'] = "";
				}

				$splitAddressFields = array(
					$address['shipfirstname'].' '.$address['shiplastname'],
					$address['shipcompany'],
					$address['shipaddress1'],
					$address['shipaddress2'],
					$address['shipcity'],
					$address['shipstate'],
					$address['shipzip'],
					$address['shipcountry']
				);

				// Please see self::GenerateShippingSelect below.
				$splitAddressFields = array_filter($splitAddressFields, array($this, 'FilterAddressFields'));
				$splitAddress = isc_html_escape(implode(', ', $splitAddressFields));
				$GLOBALS['SplitAddressList'] .= '<option value="'.$address['shipid'].'" <sel'.$address['shipid'].'>>'.$splitAddress.'</option>';

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

			$GLOBALS['SNIPPETS']['MultiShippingItem'] = '';
			if(!gzte11(ISC_MEDIUMPRINT) || !GetConfig('MultipleShippingAddresses') || !CustomerIsSignedIn() || $numItems == 1 || !isset($GLOBALS['ISC_CLASS_CHECKOUT'])) {
				$GLOBALS['HideShippingTabs'] = 'display: none';
				$GLOBALS['HideMultiShipping'] = 'display: none';
			}
			else {
				if((isset($_REQUEST['type']) && $_REQUEST['type'] == 'multiple') || getCustomerQuote()->getIsSplitShipping() && CustomerIsSignedIn()) {
					$GLOBALS['HideTabSingle'] = 'display: none';
					$GLOBALS['HideTabMultiple'] = '';
					$GLOBALS['ActiveTabSingle'] = '';
					$GLOBALS['ActiveTabMultiple'] = 'Active';
				}

				$items = getCustomerQuote()->getItems();
				foreach($items as $item) {
					// If this isn't a physical item, skip it
					if($item->getType() != PT_PHYSICAL) {
						continue;
					}
					$GLOBALS['ProductName'] = isc_html_escape($item->getName());

					// 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>";
					}


					// Loop through the cart items and add them individually to the list
					$quantity = $item->getQuantity();
					for($i = 1; $i <= $quantity; ++$i) {
						$GLOBALS['AddressFieldId'] = $item->getId().'_'.$i;
						$sel = $item->getAddressId();
						$GLOBALS['ShippingAddressSelect'] = $this->GenerateShippingSelect($GLOBALS['SplitAddressList'], $sel);
						$GLOBALS['SNIPPETS']['MultiShippingItem'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('MultiShippingItem');
					}
				}
			}
		}
コード例 #13
0
	public function insertConversionScript()
	{
		//built in conversion pages.
		$conversionPages = $this->getConversionPages();
		$conversionPage = '';

		// some configurations of IIS don't set REQUEST_URI so we fix it here, fixes ISC-537
		if (!isset($_SERVER['REQUEST_URI'])) {
			$_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];
			if (isset($_SERVER['QUERY_STRING'])) {
				$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
			}
		}

		foreach($conversionPages as $page => $url) {
			if(strpos($_SERVER["REQUEST_URI"], $url) !== false) {
				//if this is not the cart page after product is added to cart,
				if($page == 'Cart') {
					if (!isset($_SESSION['JustAddedProduct']) || $_SESSION['JustAddedProduct'] =='') {
						return;
					}
				}
				$conversionPage = $page;
				break;
			}
		}

		if($conversionPage != '') {
			$conversionScripts = $this->getConversionScriptsForPage($conversionPage);
			//$GLOBALS['OptimizerConversionScript'] .= implode(' ', $conversionScripts);
			$scripts = $GLOBALS['OptimizerConversionScript'];
			foreach($conversionScripts as $row) {
				//if it's a per product based GWO test insert the conversion script only when the action is associate to the product
				$noConversion = false;

				if($row['optimizer_type'] == 'product') {
					switch(isc_strtolower($page)) {
						case 'cart':
							if($_SESSION['JustAddedProduct'] != $row['optimizer_item_id']) {
								$noConversion = true;
							}
							break;
						case 'checkout':
							$prodInCart = array();
							$noConversion = true;
							$items = getCustomerQuote()->getItems();
							foreach($items as $item) {
								if($row['optimizer_item_id'] == $item->getProductId()) {
									$noConversion = false;
									break;
								}
							}
							break;
						case 'order':
							if(isset($_SESSION['ProductJustOrdered'])) {
								$prodOrdered = explode(',',$_SESSION['ProductJustOrdered']);
								if(!in_array($row['optimizer_item_id'], $prodOrdered)) {
									$noConversion = true;
								}
							}
						break;
					}
				}
				if($noConversion) {
					continue;
				}
				$curScript = $row['optimizer_conversion_script'];
				//merge multiple conversion script to one.
				if($scripts != '') {
					$scriptID = preg_replace("/\/goal(\s|.)*/", '', $curScript);
					$scriptID = preg_replace("/(\s|.)*trackPageview\(\"\//", '', $scriptID);

					$scriptPart = 'gwoTracker._trackPageview("/'.$scriptID.'/goal");
}catch(err){}</script>';

					$scripts = str_replace('}catch(err){}</script>',$scriptPart, $scripts);
				} else {
					$scripts = $curScript;
				}
			}

			$GLOBALS['OptimizerConversionScript'] = $scripts;
		}
	}
コード例 #14
0
		/**
		 * Add the shipping information to the google object representation of the customers cart.
		 *
		 * @return void
		 **/
		private function AddShippingInformationToCart()
		{
			$quote = getCustomerQuote();
			$noShippingCost = 0;
			$fixedShippingCost = 0;
			$fixedShippingProducts = 0;

			$items = $quote->getItems();
			foreach($items as $item) {
				if($item->getType() != PT_PHYSICAL) {
					continue;
				}

				if($item->hasFreeShipping()) {
					++$noShippingCost;
				}
				else if($item->getFixedShippingCost() > 0) {
					++$fixedShippingProducts;
					$fixedShippingCost += $item->getFixedShippingCost() * $item->getQuantity();
				}
			}

			// Global free shipping options
			$addFreeShipping = false;
			if ($quote->getHasFreeShipping() || $noShippingCost)
			{
				$freeShippingName = GetLang('FreeShipping');
				$addFreeShipping = true;
			}

			// Global fixed shipping on items option
			$addFixedShipping = false;
			if (count($items) == $fixedShippingProducts) {
				$fixedShippingName = GetConfig('StoreName');
				$addFixedShipping = true;
			}

			// Not all the products have a fixed shipping so keep on chugging away
			$shippingZones = GetShippingZoneInfo();

			// Do all the normal zones first (skip the default one)
			// this is so that we can work out where "everywhere else" equates to
			foreach ($shippingZones as $shippingZone) {
				// Skip the default zone for now
				if (!isset($shippingZone['locationtype'])) {
					continue;
				}

				$shippingRestrictions = $this->GetShippingRestrictions($shippingZone);
				$this->AddDefaultShippingRestrictions($shippingZone);

				// Add in the free shipping option if we have it
				if($addFreeShipping || !empty($shippingZone['zonefreeshipping'])) {
					$freeShippingName = GetLang('FreeShipping');
					$ship = new GoogleMerchantCalculatedShipping($freeShippingName . ' ('.$shippingZone['zonename'].')', 0);
					if ($shippingRestrictions !== false) {
						// Address filters are used when a customer goes to the google checkout page
						$ship->AddAddressFilters($shippingRestrictions);

						// Shipping restrictions are used if the merchant callback calculation fails
						$ship->AddShippingRestrictions($shippingRestrictions);
					}

					$ship->AddAddressFilters($shippingRestrictions);
					$this->cart->AddShipping($ship);
				}

				// Add in the fixed shipping option if we have it
				if($addFixedShipping) {
					$ship = new GoogleMerchantCalculatedShipping($fixedShippingName . ' ('.$shippingZone['zonename'].')', $fixedShippingCost);
					if ($shippingRestrictions !== false) {
						// Address filters are used when a customer goes to the google checkout page
						$ship->AddAddressFilters($shippingRestrictions);

						// Shipping restrictions are used if the merchant callback calculation fails
						$ship->AddShippingRestrictions($shippingRestrictions);
					}

					$ship->AddAddressFilters($shippingRestrictions);
					$this->cart->AddShipping($ship);
				}

				$this->AddShippingZoneMethodsToCart($shippingZone, $shippingRestrictions, $fixedShippingCost, true);
			}

			// Now add the methods for the default zone
			foreach ($shippingZones as $shippingZone) {
				// Skip any non-default zones now
				if (isset($shippingZone['locationtype'])) {
					continue;
				}

				// Add free shipping options
				if ($addFreeShipping || !empty($shippingZone['zonefreeshipping']))
				{
					$freeShippingName = GetLang('FreeShipping');
					$ship = new GoogleMerchantCalculatedShipping($freeShippingName, 0);
					$Gfilter = new GoogleShippingFilters();
					$Gfilter->SetAllowedWorldArea(true);
					$ship->AddAddressFilters($Gfilter);

					if ($this->defaultZoneGFilter) {
						// Address filters are used when a customer goes to the google checkout page
						$ship->AddAddressFilters($this->defaultZoneGFilter);

						// Shipping restrictions are used if the merchant callback calculation fails
						$ship->AddShippingRestrictions($this->defaultZoneGFilter);
					}

					$this->cart->AddShipping($ship);
				}

				// Add fixed shipping on items option
				if ($addFixedShipping) {
					$Gfilter = new GoogleShippingFilters();
					$ship = new GoogleMerchantCalculatedShipping($fixedShippingName, $fixedShippingCost);
					$Gfilter->SetAllowedWorldArea(true);
					$ship->AddAddressFilters($Gfilter);

					if ($this->defaultZoneGFilter) {
						// Address filters are used when a customer goes to the google checkout page
						$ship->AddAddressFilters($this->defaultZoneGFilter);

						// Shipping restrictions are used if the merchant callback calculation fails
						$ship->AddShippingRestrictions($this->defaultZoneGFilter);
					}

					$this->cart->AddShipping($ship);
				}

				$this->AddShippingZoneMethodsToCart($shippingZone, $this->defaultZoneGFilter, $fixedShippingCost, false);
			}
		}
コード例 #15
0
ファイル: orders.php プロジェクト: hungnv0789/vhtm
/**
 * Completes a pending order and marks it's status as whatever it should be next.
 * This function will process any payments, capture amounts from gateways, increase
 * # sold for each product in the order, etc.
 *
 * @param string The pending order token.
 * @param int The status to set the completed order to.
 * @return boolean True if successful, false on failure.
 */
function CompletePendingOrder($pendingOrderToken, $status, $sendInvoice=true)
{
	$orderData = LoadPendingOrdersByToken($pendingOrderToken, true);
	if($orderData === false) {
		return false;
	}

	$processedStoreCredit = false;
	$processedGiftCertificates = false;
	$orderStoreCredit = 0;
	$orderTotalAmount = 0;

	// Flag used to create the customer record but only if atleast one order was successful
	$createCustomer = false;

	// Sum up our total amount and store credit
	foreach ($orderData['orders'] as $order) {
		if ($order['ordstatus'] != 0) {
			continue;
		}

		$orderStoreCredit += $order['ordstorecreditamount'];
		$orderTotalAmount += $order['total_inc_tax'];
	}

	// flag to indicate if we should send notifications? only if the order was previously incomplete and the new status isn't declined/cancelled/refunded
	$sendNotifications = false;

	foreach($orderData['orders'] as $order) {
		$newStatus = $status;

		// Wait, was the order already complete? Then we don't do anything
		if($order['ordstatus'] != ORDER_STATUS_INCOMPLETE) {
			continue;
		}

		// If this order is digital, and the status is awaiting fulfillment, there's nothing
		// to actually fulfill, so set it to completed.
		if($order['ordisdigital'] && $newStatus == ORDER_STATUS_AWAITING_FULFILLMENT) {
			$newStatus = ORDER_STATUS_COMPLETED;
		}

		$extraInfo = @unserialize($order['extrainfo']);
		if(!is_array($extraInfo)) {
			$extraInfo = array();
		}

		// only email and update order data (coupons, certificates, store credit etc) if it's not a declined, cancelled or refunded order
		if($newStatus != ORDER_STATUS_DECLINED && $newStatus != ORDER_STATUS_CANCELLED && $newStatus != ORDER_STATUS_REFUNDED) {
			$createCustomer = true;
			$sendNotifications = true;

			if($sendInvoice && !EmailInvoiceToCustomer($order['orderid'], $newStatus)) {
				$GLOBALS['HideError'] = "";
				$GLOBALS['ErrorMessage'] = GetLang('ErroSendingInvoiceEmail');
				$GLOBALS['HideSuccess'] = "none";
			}

			// Are we updating the inventory levels when an order has been placed?
			if(GetConfig('UpdateInventoryLevels') == 1) {
				DecreaseInventoryFromOrder($order['orderid']);
			}

			// If this order now complete, we need to activate any gift certificates
			if(OrderIsComplete($newStatus)) {
				$GLOBALS['ISC_CLASS_GIFTCERTIFICATES'] = GetClass('ISC_GIFTCERTIFICATES');
				$GLOBALS['ISC_CLASS_GIFTCERTIFICATES']->ActivateGiftCertificates($order['orderid']);
			}

			// If we've had one or more coupons been applied to this order, we now need to increment the number of uses
			$couponIds = array();
			$query = "
				SELECT *
				FROM [|PREFIX|]order_coupons
				WHERE ordcouporderid='".(int)$order['orderid']."'
			";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			while($coupon = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$couponIds[] = $coupon['ordcouponid'];
			}
			if(!empty($couponIds)) {
				$couponsUsed = array_unique($couponIds);
				$couponList = implode(",", array_map("intval", $couponsUsed));
				$query = "
					UPDATE [|PREFIX|]coupons
					SET couponnumuses=couponnumuses+1
					WHERE couponid IN (".$couponList.")
				";
				$GLOBALS['ISC_CLASS_DB']->Query($query);

				foreach ($couponIds as $cid) {
					getclass('ISC_COUPON')->updatePerCustomerUsage($cid);
				}
			}

			// If we used store credit on this order, we now need to subtract it from the users account.
			if($order['ordstorecreditamount'] > 0 && $processedStoreCredit == false) {
				$GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');
				$currentCredit = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerStoreCredit($order['ordcustid']);
				$newCredit = $currentCredit - $orderStoreCredit;
				if($newCredit < 0) {
					$newCredit = 0;
				}
				$updatedCustomer = array(
					'custstorecredit' => $newCredit,
				);
				$GLOBALS['ISC_CLASS_DB']->UpdateQuery('customers', $updatedCustomer, "customerid='".(int)$order['ordcustid']."'");
				$processedStoreCredit = true;
			}

			// If one or more gift certificates were used we need to apply them to this order and subtract the total
			if($order['ordgiftcertificateamount'] > 0 && isset($extraInfo['giftcertificates']) && !empty($extraInfo['giftcertificates']) && $processedGiftCertificates == false) {
				$usedCertificates = array();
				$GLOBALS['ISC_CLASS_GIFT_CERTIFICATES'] = GetClass('ISC_GIFTCERTIFICATES');
				$GLOBALS['ISC_CLASS_GIFT_CERTIFICATES']->ApplyGiftCertificatesToOrder($order['orderid'], $orderTotalAmount + $order['ordgiftcertificateamount'], $extraInfo['giftcertificates'], $usedCertificates);
				unset($extraInfo['giftcertificates']);
				$processedGiftCertificates = true;
			}

			// If there are one or more digital products in this order then we need to create a record in the order_downloads table
			// for each of them and set the expiry dates
			$query = "
				SELECT ordprodid, ordprodqty
				FROM [|PREFIX|]order_products
				WHERE orderorderid='".$order['orderid']."' AND ordprodtype='digital'
			";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$digitalProductIds = array();
			while($digitalProduct = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$digitalProductIds[$digitalProduct['ordprodid']] = $digitalProduct;
			}

			if(!empty($digitalProductIds)) {
				$query = "
					SELECT downloadid, productid, downexpiresafter, downmaxdownloads
					FROM [|PREFIX|]product_downloads
					WHERE productid IN (".implode(',', array_keys($digitalProductIds)).")
				";
				$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
				while($digitalDownload = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
					$expiryDate = 0;

					// If this download has an expiry date, set it to now + expiry time
					if($digitalDownload['downexpiresafter'] > 0) {
						$expiryDate = time() + $digitalDownload['downexpiresafter'];
					}

					// If they've purchased more than one, we need to give them max downloads X quantity downloads
					$quantity = $digitalProductIds[$digitalDownload['productid']]['ordprodqty'];

					$newDownload = array(
						'orderid' => $order['orderid'],
						'downloadid' => $digitalDownload['downloadid'],
						'numdownloads' => 0,
						'downloadexpires' => $expiryDate,
						'maxdownloads' => $digitalDownload['downmaxdownloads'] * $quantity
					);
					$GLOBALS['ISC_CLASS_DB']->InsertQuery('order_downloads', $newDownload);
				}
			}
		}

		// Does a customer account need to be created?
		if(!empty($extraInfo['createAccount'])) {
			createOrderCustomerAccount($order, $extraInfo['createAccount']);
			unset($extraInfo['createAccount']);
		}

		// Now update the order and set the status
		$updatedOrder = array(
			"ordstatus" => $newStatus,
			"extrainfo" => serialize($extraInfo)
		);
		$GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $updatedOrder, "orderid='".$order['orderid']."'");
	}

	if($sendNotifications) {
		// Trigger all active new order notification methods
		SendOrderNotifications($pendingOrderToken);

		// Do we need to add them to a Interspire Email Marketer mailing list?
		SubscribeCustomerToLists($pendingOrderToken);

		// Update the current uses of each rule
		$quote = getCustomerQuote();
		$appliedRules = array_keys(getCustomerQuote()->getAppliedDiscountRules());
		if(!empty($appliedRules)) {
			require_once ISC_BASE_PATH.'/lib/rule.php';
			updateRuleUses($appliedRules);
		}
	}

	// Empty the users cart and kill the checkout process
	EmptyCartAndKillCheckout();

	return true;
}
コード例 #16
0
	protected function _ConstructPostData($postData)
	{

		$billingDetails = $this->GetBillingDetails();
		$billState = '';
		if ($billingDetails['ordbillcountrycode'] == 'US' || $billingDetails['ordbillcountrycode'] == 'CA') {
			$billState = GetStateISO2ById($billingDetails['ordbillstateid']);
		}

		$shippingDetails = $this->getShippingAddress();
		$shipState = '';
		if ($shippingDetails['country_iso2'] == 'US' || $shippingDetails['country_iso2'] == 'CA') {
			$shipState = GetStateISO2ById($shippingDetails['state_id']);
		}


		switch ($postData['cctype']) {
			case 'VISA':
				$cctype = '001';
				break;
			case 'MC':
				$cctype = '002';
				break;
			case 'AMEX':
				$cctype = '003';
				break;
			case 'DISCOVER':
				$cctype = '004';
				break;
			case 'DINERS':
				$cctype = '005';
				break;
			case 'JCB':
				$cctype = '007';
				break;
			case 'MAESTRO':
			case 'SOLO':
				$cctype = '024';
				break;
			case 'LASER':
				$cctype = '035';
				break;
		}

		$quote = getCustomerQuote();

		$xml = array(
			'merchantID' => $this->GetValue('merchantid'),
			'merchantReferenceCode' => $this->GetCombinedOrderId(),
			'ccAuthService' => array(
				'run' => 'true',
			),
			'clientLibrary' => 'PHP',
			'clientLibraryVersion' => phpversion(),
			'clientEnvironment' => php_uname(),
			'billTo' => array(
				'firstName' 	=> $billingDetails['ordbillfirstname'],
				'lastName'		=> $billingDetails['ordbilllastname'],
				'company'		=> $billingDetails['ordbillcompany'],
				'street1'		=> $billingDetails['ordbillstreet1'],
				'city'			=> $billingDetails['ordbillsuburb'],
				'state'			=> $billState,
				'country'		=> $billingDetails['ordbillcountrycode'],
				'postalCode'	=> $billingDetails['ordbillzip'],
				'email'			=> $billingDetails['ordbillemail'],
				'phoneNumber'	=> $billingDetails['ordbillphone'],
			),
			'shipTo' => array(
				'firstName' 	=> $shippingDetails['first_name'],
				'lastName'		=> $shippingDetails['last_name'],
				'company'		=> $shippingDetails['company'],
				'street1'		=> $shippingDetails['address_1'],
				'street2'		=> $shippingDetails['address_2'],
				'city'			=> $shippingDetails['city'],
				'state'			=> $shipState,
				'country'		=> $shippingDetails['country_iso2'],
				'postalCode'	=> $shippingDetails['zip'],
				'email'			=> $shippingDetails['email'],
				'phoneNumber'	=> $shippingDetails['phone'],
			),
			'purchaseTotals' => array(
				'currency' => GetCurrencyCodeByID($this->GetCurrency()),
				'grandTotalAmount' => number_format($this->GetGatewayAmount(), 2, '.', ''),
			),
		);

		$ip = GetIP();
		if ($ip) {
			$xml['billTo']['ipAddress'] = $ip;
		}

		// are we doing a sale ?
		if ($this->GetValue('transactiontype') == 'SALE') {
			$xml['ccCaptureService'] = array(
				'run' => 'true',
			);
		}

		$card = array(
			'fullName'			=> $postData['name'],
			'accountNumber' 	=> $postData['ccno'],
			'expirationMonth' 	=> $postData['ccexpm'],
			'expirationYear' 	=> '20' . $postData['ccexpy'],
			'cardType' 			=> $cctype,
		);
		if ($this->GetValue('cardcode') == 'YES') {
			$card['cvNumber'] = $postData['cccvd'];
		}
		if ($this->CardTypeRequiresIssueNoOrDate($postData['cctype'])) {
			$card['issueNumber'] = $postData['ccissueno'];
			$card['startMonth'] = $postData['ccissuedatem'];
			$card['startYear'] = $postData['ccissuedatey'];
		}

		$xml['card'] = $card;

		// add items to order
		$x = 0;
		$items = array();
		foreach ($quote->getItems() as /** @var ISC_QUOTE_ITEM */$item) {
			$itemXml = array(
				'productName' 	=> $item->getName(),
				'productSKU'	=> $item->getSku(),
				'unitPrice'		=> number_format($item->getPrice(), '2', '.', ''),
				'quantity'		=> $item->getQuantity(),
				'id'			=> (string)$x,
			);

			$items[] = $itemXml;

			$x++;
		}

		if (!empty($items)) {
			$xml['items'] = $items;
		}

		return $xml;
	}
コード例 #17
0
ファイル: class.remote.php プロジェクト: hungnv0789/vhtm
		/**
		 * Retrieve a list of shipping quotes for a customer estimating their shipping on the 'View Cart' page.
		 */
		private function GetShippingQuotes()
		{
			if(empty($_POST['countryId']) || empty($_POST['zipCode'])) {
				exit;
			}

			$statesList = GetStateListAsIdValuePairs((int)$_POST['countryId']);
			if (!empty($statesList) && empty($_POST['stateId'])) {
				exit;
			}

			// Cart page shipping quotes don't support split shipping
			$quote = getCustomerQuote();
			$quote->setIsSplitShipping(false);

			$shippingAddress = $quote->getShippingAddress();
			$billingAddress = $quote->getBillingAddress();

			$shippingAddress->setCountryById($_POST['countryId']);
			$billingAddress->setCountryById($_POST['countryId']);
			if(!empty($_POST['stateId'])) {
				$shippingAddress->setStateById($_POST['stateId']);
				$billingAddress->setStateById($_POST['stateId']);
			}
			if(!empty($_POST['zipCode'])) {
				$shippingAddress->setZip($_POST['zipCode']);
				$billingAddress->setZip($_POST['zipCode']);
			}

			$quote->addShippingAddress($shippingAddress);
			$shippingMethods = $shippingAddress->getAvailableShippingMethods();
			if(empty($shippingMethods)) {
				echo getLang('UnableEstimateShipping');
				exit;
			}

			// Keeping this for legacy purposes for now
			$GLOBALS['HideVendorDetails'] = 'display: none';
			$GLOBALS['ShippingQuotesListNote'] = '';
			$GLOBALS['HideShippingQuotesListNote'] = 'display: none';
			$GLOBALS['VendorShippingQuoteClass'] = '';
			$GLOBALS['HideShippingItemList'] = 'display: none';

			$hasTransit = false;
			$GLOBALS['ShippingQuoteRow'] = '';
			foreach($shippingMethods as $quoteId => $method) {
				$price = getClass('ISC_TAX')->getPrice(
					$method['price'],
					getConfig('taxShippingTaxClass'),
					getConfig('taxDefaultTaxDisplayCart'),
					$shippingAddress->getApplicableTaxZone()
				);
				$GLOBALS['ShipperName'] = isc_html_escape($method['description']);
				$GLOBALS['ShippingPrice'] = CurrencyConvertFormatPrice($price);
				$GLOBALS['ShippingQuoteId'] = $quoteId;

				$GLOBALS['TransitTime'] = "";
				if(isset($method['transit'])) {
					$hasTransit = true;
					$days = $method['transit'];
					if ($days == 0) {
						$transit = GetLang("SameDay");
					}
					else if ($days == 1) {
						$transit = GetLang('NextDay');
					}
					else {
						$transit = sprintf(GetLang('Days'), $days);
					}

					$GLOBALS['TransitTime'] = $transit;
					$GLOBALS['TransitTime'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CartShippingTransitTime');
				}

				$GLOBALS['ShippingQuoteRow'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CartShippingQuoteRow');
			}

			$GLOBALS['ShippingQuotes'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('EstimatedShippingQuote');

			if ($hasTransit) {
				$GLOBALS['DeliveryDisclaimer'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CartShippingDeliveryDisclaimer');
			}

			echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('EstimatedShippingQuoteList');
		}
コード例 #18
0
ファイル: class.customer.php プロジェクト: hungnv0789/vhtm
		private function CreateAccountStep2()
		{
			$savedataDetails = array(

				/**
				 * Customer Details
				 */
				FORMFIELDS_FORM_ACCOUNT => array(
					'EmailAddress' => 'custconemail',
					'Password' => 'custpassword',
					'ConfirmPassword' => 'custconfirmpassword',
					'FirstName' => 'custconfirstname',
					'LastName' => 'custconlastname',
					'CompanyName' => 'custconcompany',
					'Phone' => 'custconphone',
				),

				/**
				 * Shipping Details
				 */
				FORMFIELDS_FORM_ADDRESS => array(
					'FirstName' => 'shipfirstname',
					'LastName' => 'shiplastname',
					'CompanyName' => 'shipcompany',
					'AddressLine1' => 'shipaddress1',
					'AddressLine2' => 'shipaddress2',
					'City' => 'shipcity',
					'State' => 'shipstate',
					'Country' => 'shipcountry',
					'Zip' => 'shipzip',
					'Phone' => 'shipphone',
					'BuildingType' => 'shipdestination'
				)
			);

			/**
			 * Validate and map submitted field data in one loop
			 */
			$fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT, true);
			$fields += $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ADDRESS, true);
			$customerData = array();
			$shippingData = array();
			$password = '';
			$confirmPassword = '';

			foreach (array_keys($fields) as $fieldId) {

				/**
				 * Validate
				 */
				$errmsg = '';
				if (!$fields[$fieldId]->runValidation($errmsg)) {
					return $this->CreateAccountStep1($errmsg);
				}

				foreach ($savedataDetails as $type => $map) {

					/**
					 * Are we in the customer section or the shipping?
					 */
					if ($type == FORMFIELDS_FORM_ACCOUNT) {
						$referencedData =& $customerData;
					} else {
						$referencedData =& $shippingData;
					}

					/**
					 * We're only interested in the private custom fields here
					 */
					if (array_key_exists($fields[$fieldId]->record['formfieldprivateid'], $map)) {
						$label = $map[$fields[$fieldId]->record['formfieldprivateid']];
						$referencedData[$label] = $fields[$fieldId]->getValue();

						/**
						 * Store the values somewhere if this is a apssword/confirm-password field
						 */
						if ($fields[$fieldId]->record['formfieldprivateid'] == 'Password') {
							$password = $referencedData[$label];
						} else if ($fields[$fieldId]->record['formfieldprivateid'] == 'ConfirmPassword') {
							$confirmPassword = $referencedData[$label];
						}
					}
				}
			}

			/**
			 * Clean up some of the data
			 */
			if (isset($shippingData['shipstate'])) {
				$state = GetStateInfoByName($shippingData['shipstate']);
				if ($state) {
					$shippingData['shipstateid'] = $state['stateid'];
				} else {
					$shippingData['shipstateid'] = '';
				}
			}
			if (isset($shippingData['shipcountry'])) {
				$countryId = GetCountryByName($shippingData['shipcountry']);
				if (isId($countryId)) {
					$shippingData['shipcountryid'] = $countryId;
				} else {
					$shippingData['shipcountryid'] = '';
				}
			}
			if (isset($shippingData['shipdestination'])) {
				$data = $fields[$fieldId]->getValue();
				if (isc_strtolower($shippingData[$label]) == 'house') {
					$shippingData[$label] = 'residential';
				} else {
					$shippingData[$label] = 'commercial';
				}
			}

			// Does an account with this email address already exist?
			if ($this->AccountWithEmailAlreadyExists($customerData['custconemail'])) {
				$this->CreateAccountStep1("already_exists");
			}
			// Else is the provided phone number valid?
			else if (!$this->ValidatePhoneNumber($customerData['custconphone'])) {
				$this->CreateAccountStep1("invalid_number");
			}
			// Else the passwords don't match
			else if ($password !== $confirmPassword) {
				$this->CreateAccountStep1("invalid_passwords");
			}
			else {
				// Create the user account in the database
				$token = GenerateCustomerToken();
				$customerData['customertoken'] = $token;

				// Add in the form sessions here AFTER all the validation
				$accountFormSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ACCOUNT);

				if (isId($accountFormSessionId)) {
					$customerData['custformsessionid'] = $accountFormSessionId;
				}

				$shippingFormSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ADDRESS);

				if (isId($shippingFormSessionId)) {
					$shippingData['shipformsessionid'] = $shippingFormSessionId;
				}

				$customerData["addresses"] = array($shippingData);
				$_SESSION['FROM_REG'] = 0;
				$customerId = $this->CreateCustomerAccount($customerData);

				if (isId($customerId)) {

					// The account was created, let's log them in automatically
					$this->LoginCustomerById($customerId, true);

					// Show the "thank you for registering" page
					if (isset($_SESSION['LOGIN_REDIR']) && $_SESSION['LOGIN_REDIR'] != '') {
						$GLOBALS['Continue'] = GetLang('ClickHereToContinue');
						$GLOBALS['ContinueLink'] = urldecode($_SESSION['LOGIN_REDIR']);
						$_SESSION['FROM_REG'] = 1;
					}
					// User has just registered (not in the middle of an order - click here to visit your account)
					else {
						$GLOBALS['Continue'] = GetLang('ClickHereContinueShopping');
						$GLOBALS['ContinueLink'] = $GLOBALS['ShopPath'];
					}
					$GLOBALS['ISC_LANG']['CreateAccountThanksIntro'] = sprintf(GetLang('CreateAccountThanksIntro'), $GLOBALS['StoreName'], isc_html_escape($customerData['custconemail']));
					$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(GetConfig('StoreName') . " - " . GetLang('CreateAccountThanks'));

					if (!isset($_SESSION['IsCheckingOut'])) {
						// Take them to the default thank you page if they aren't checking out
						$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("createaccount_thanks");
						$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
					}
					else {

						/**
						 * This is an order so take them straight to the shipping provider page. Also save the
						 * shipping address here as we will need the custom fields
						 */
						if (getCustomerQuote()->getIsSplitShipping()) {
							header("Location: " . $GLOBALS['ShopPath'] . "/checkout.php?action=multiple");
						}
						else {
							header("Location: " . $GLOBALS['ShopPath'] . "/checkout.php");
						}

					}

					die();
				}
				else {
					// Couldn't create the account
					$this->CreateAccountStep1("database_error");
				}
			}
		}
コード例 #19
0
	public function SetPanelSettings()
	{
		if (!isset($GLOBALS['ProductJustAdded']) || !$GLOBALS['ProductJustAdded']) {
			$this->DontDisplay = true;
			return;
		}

		$limit = 8;
		if (isset($GLOBALS['SuggestiveCartContentLimit'])) {
			$limit = (int)$GLOBALS['SuggestiveCartContentLimit'];
		}

		$count = 0;
		$prod_ids = array();
		$output = "";

		$GLOBALS['SuggestedProductListing'] = "";

		// Hide the "compare" checkbox for each product
		$GLOBALS['HideCompareItems'] = "none";

		// Make sure the query doesn't return the product we're adding to
		// the cart or any other products in the cart for that matter
		$ignore_prod_list = getCustomerQuote()->getUniqueProductIds();
		$ignore_prod_list = implode(',', $ignore_prod_list);
		if($ignore_prod_list == "") {
			$ignore_prod_list = 0;
		}
		$query = "
			SELECT ordprodid
			FROM [|PREFIX|]order_products
			WHERE orderorderid IN (
				SELECT orderorderid FROM [|PREFIX|]order_products WHERE ordprodid='".(int)$GLOBALS['ProductJustAdded']."'
			) AND ordprodid NOT IN (".$ignore_prod_list.")
			GROUP BY ordprodid
			ORDER BY COUNT(ordprodid) DESC
		";
		$query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, $limit);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

		// Get the list of suggested product id's
		while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$prod_ids[] = $row['ordprodid'];
		}

		$suggest_prod_ids = implode(",", $prod_ids);

		$remaining_places = $limit -count($prod_ids);
		// If there aren't enough products to suggest, we will get
		// the popular products (based on reviews) instead

		// If there aren't enough suggested products, fetch related products for this item
		if($remaining_places > 0) {
			require_once(APP_ROOT."/includes/classes/class.product.php");
			$related = GetRelatedProducts($GLOBALS['Product']['productid'], $GLOBALS['Product']['prodname'], $GLOBALS['Product']['prodrelatedproducts']);

			// Any returned products? add them to the list
			$relatedProducts = explode(",", $related);
			// Limit the number of products to the # of empty spaces we have
			for($i = 0; $i < $remaining_places; ++$i) {
				if(!isset($relatedProducts[$i]) || $relatedProducts[$i] == "") {
					break;
				}

				if(!in_array($relatedProducts[$i], $prod_ids) && !@in_array($relatedProducts[$i], $ignore_prod_list)) {
					$prod_ids[] = $relatedProducts[$i];
				}

			}

			$remaining_places = $limit -count($prod_ids);
			$suggest_prod_ids = implode(",", $prod_ids);
		}
		// Still don't have enough? Fetch popular products
		if($remaining_places > 0) {
			if(!$suggest_prod_ids) {
				$suggest_prod_ids = 0;
			}

			$query = sprintf("select productid, floor(prodratingtotal/prodnumratings) as prodavgrating from [|PREFIX|]products where productid not in (%s) and productid not in (%s) and prodvisible='1' order by prodavgrating desc", $suggest_prod_ids, $ignore_prod_list);
			$query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, $remaining_places);
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			// Is there at least one product to suggest?
			while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$prod_ids[] = $row['productid'];
			}

			$suggest_prod_ids = implode(",", $prod_ids);
		}

		// If there are *still* no products to suggest, just show them
		// the normal shopping cart view instead

		if(!empty($prod_ids)) {
			// Get a list of products that were ordered at the
			// same time as the product that was just added to the cart
			if(!$suggest_prod_ids) {
				$suggest_prod_ids = 0;
			}

			if(!getProductReviewsEnabled()) {
				$GLOBALS['HideProductRating'] = "display: none";
			}

			$query = $this->getProductQuery(
				'p.productid IN ('.$suggest_prod_ids.')',
				'p.prodnumsold DESC, p.prodratingtotal DESC'
			);
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			$GLOBALS['AlternateClass'] = '';
			while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$this->setProductGlobals($row);
				$GLOBALS['SuggestedProductListing'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryProductsItem");
			}
		}

		if(!$GLOBALS['SuggestedProductListing']) {
			ob_end_clean();
			header("Location:cart.php");
			die();
		}
	}
コード例 #20
0
ファイル: class.order.php プロジェクト: hungnv0789/vhtm
		/**
		*	Complete the order after the customer is brought back from the payment provider
		*/
		public function FinishOrder()
		{
			// Orders are still incomplete, so we need to validate them
			if($this->pendingData['status'] == ORDER_STATUS_INCOMPLETE) {
				// Verify the pending order
				$newStatus = VerifyPendingOrder($this->orderToken);

				// Order was declined and we're rejecting all declined payments
				if($newStatus == ORDER_STATUS_DECLINED) {
					$Msg = sprintf(GetLang('ErroOrderDeclined'), GetConfig('OrderEmail'), GetConfig('OrderEmail'));
					$this->BadOrder(GetLang('YourPaymentWasDeclined'), $Msg);
				}
				// This order is valid
				elseif($newStatus !== false) {

					$prodOrdered = array();
					$items = getCustomerQuote()->getItems();
					foreach($items as $item) {
						$productId = $item->getProductId();
						if($productId > 0) {
							$prodOrdered[] = $productId;
						}
						$_SESSION['ProductJustOrdered'] = implode(',',$prodOrdered);
					}
					if(CompletePendingOrder($this->orderToken, $newStatus)) {
						// Order was saved. Show the confirmation screen and email an invoice to the customer
						$this->ThanksForYourOrder();
						return;
					}
				}

				// If we're still here, either the order didnt complete or the order was invalid
				$this->BadOrder();
			}
			// Order is already complete - there's a good chance the customer has refreshed the page,
			// or they've come back from somewhere like PayPal who in the mean time has already sent
			// us a ping back to validate and begin processing the order - show the thank you page
			else if($this->pendingData['status'] == ORDER_STATUS_DECLINED) {
					$Msg = sprintf(GetLang('ErroOrderDeclined'), GetConfig('OrderEmail'), GetConfig('OrderEmail'));
					$this->BadOrder(GetLang('YourPaymentWasDeclined'), $Msg);
			}
			else {
				$this->ThanksForYourOrder();
				return;
			}
		}
コード例 #21
0
		/**
		* Set Express Checkout step in Paypal Express checkout
		* it sends cart details to paypal and redirect customer to paypal login page.
		*
		*/
		private function SetExpressCheckout()
		{

			$currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));

			$merchant = $this->GetMerchantSettings();

			$quote = getCustomerQuote();
			$amount = $quote->getGrandTotal();

			$shippingDetails = array();
			//if user click the paypal button on order confirmation page
			if(isset($_COOKIE['SHOP_ORDER_TOKEN'])) {
				$userAction = '&useraction=commit';
				$orders = $this->GetOrders();
				reset($orders);
				$order = current($orders);
				$orderId = '#'.implode(', #', array_keys($orders));

				if($order['ordisdigital']) {
					$shippingDetails = array (
						'NOSHIPPING' => 1,
					);
				} else {
					$shippingAddress = $this->getShippingAddress();
					$shippingDetails = array (
						'NAME' => $shippingAddress['first_name']." ".$shippingAddress['last_name'],
						'SHIPTOSTREET' => $shippingAddress['address_1'],
						'SHIPTOSTREET2' => $shippingAddress['address_2'],
						'SHIPTOCITY' => $shippingAddress['city'],
						'SHIPTOZIP' => $shippingAddress['zip'],
						'SHIPTOCOUNTRY' => $shippingAddress['country_iso2'],
						'PHONENUM' => $shippingAddress['phone'],
					);

					if($shippingAddress['state_id'] != 0 && GetStateISO2ById($shippingAddress['state_id'])) {
						$shippingDetails['SHIPTOSTATE'] = GetStateISO2ById($shippingAddress['state_id']);
					}
					else {
						$shippingAddress['SHIPTOSTATE'] = isc_html_escape($shippingAddress['state']);
					}
				}

				//don't display shipping address in PayPal
				$addressOverride = 1;
			} else {
				$userAction = '&useraction=continue';
				//display shipping address in PayPal
				$addressOverride = 0;
			}

			if($merchant['testmode'] == 'YES') {
				$transactionURL = $this->_testTransactionURL;
				$transactionURI = $this->_testTransactionURI;
				$PaypalExpressCheckoutURL = 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=';
			}
			else {
				$transactionURL = $this->_liveTransactionURL;
				$transactionURI = $this->_liveTransactionURI;
				$PaypalExpressCheckoutURL = 'https://www.paypal.com/webscr&cmd=_express-checkout&token=';
			}

			$pp_array = array(
				'METHOD'		=> 'SetExpressCheckout',
				'USER'			=> $merchant['username'],
				'PWD'			=> $merchant['password'],
				'SIGNATURE'		=> $merchant['signature'],
				'VERSION'		=> '53.0',
				'PAYMENTACTION'		=> $merchant['transactionType'],

				'AMT'			=> number_format($amount,2,'.',''),
				'CURRENCYCODE'		=> $currency,
				'PAYMENTACTION'		=> $merchant['transactionType'],

				'RETURNURL'		=> $GLOBALS['ShopPath']."/checkout.php?action=set_external_checkout&provider=paypalexpress",
				'CANCELURL'		=> $GLOBALS['ShopPath']."/cart.php",
				'ADDRESSOVERRIDE'	=> $addressOverride,
				'NOTIFYURL'		=> $GLOBALS['ShopPath'].'/checkout.php?action=gateway_ping&provider='.$this->GetId(),
				'L_NAME0'		=> getLang('YourOrderFromX', array('storeName' => getConfig('StoreName'))),
				'L_AMT0'		=> number_format($amount,2,'.',''),
				'L_QTY0'		=> 1,
			);

			//if shipping details are known here, which happens when user chose paypay express checkout at normal  order confirmation page
			if(!empty($shippingDetails)) {
				$pp_array = array_merge($pp_array, $shippingDetails);
			}
			$paypal_query = '';
			foreach ($pp_array as $key => $value) {
				$paypal_query .= $key.'='.urlencode($value).'&';
			}
			$paypal_query = rtrim($paypal_query, '&');

			$result = $this->_ConnectToProvider($transactionURL, $transactionURI, $paypal_query);
			$nvpArray = $this->_DecodePaypalResult($result);

			//if data is sent to paypal successfully, a token for this transaction will return from paypal
			if(strtolower($nvpArray['ACK']) == 'success') {
				// Redirect to paypal.com here
				$token = $nvpArray["TOKEN"];
				$PayPalURL = $PaypalExpressCheckoutURL.$token.$userAction;
				header("Location: ".$PayPalURL);
			} else {
				$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment',  $this->GetName()), GetLang('ErrorConnectingToPaypal'), $nvpArray['L_ERRORCODE0']." ".$nvpArray['L_LONGMESSAGE0']);
				flashMessage(getLang('ErrorConnectingToPaypal'), MSG_ERROR, 'cart.php');
			}
		}
コード例 #22
0
		private function SetExpressCheckout()
		{
			$currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));

			$merchant = $this->GetMerchantSettings();

			$quote = getCustomerQuote();
			$amount = $quote->getGrandTotal();

			if($merchant['testmode'] == 'YES') {
				$transactionURL = $this->_testTransactionURL;
				$transactionURI = $this->_testTransactionURI;
				$PaypalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=';
			}
			else {
				$transactionURL = $this->_liveTransactionURL;
				$transactionURI = $this->_liveTransactionURI;
				$PaypalURL = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=';
			}

			$pp_array = array(
								'ACTION'			=> 'S',
								'TRXTYPE'			=> $merchant['transactionType'],
								'AMT'				=> number_format($amount,2,'.',''),
								'CANCELURL'			=> $GLOBALS['ShopPath']."/cart.php",
								'PARTNER'			=> $merchant['partnerid'],

								'TENDER'			=> 'P',
								'USER'				=> $merchant['userid'],
								'PWD'				=> $merchant['password'],
								'VENDOR'			=> $merchant['vendorid'],
								'CURRENCY'			=> $currency,
								'REQCONFIRMSHIPPING'=> 1,
								'NOSHIPPING'		=> 0,
								'RETURNURL'			=> $GLOBALS['ShopPath']."/checkout.php?action=set_external_checkout&provider=paypalpaymentsprouk",
								'NOTIFYURL'			=> $GLOBALS['ShopPath'].'/checkout.php?action=gateway_ping&provider='.$this->GetId(),
							);

			$paypal_query = '';
			foreach ($pp_array as $key => $value) {
				$paypal_query .= $key.'['.strlen($value).']='.$value. '&';
			}
			$paypal_query = rtrim($paypal_query, '&');

			$result = $this->_ConnectToProvider($transactionURL, $transactionURI, $paypal_query, uniqid(rand()));
			$nvpArray = $this->_DecodePaypalResult($result);


			if($nvpArray['RESULT'] == 0) {
				// Redirect to paypal.com here
				$token = $nvpArray["TOKEN"];
				$PaypalURL = $PaypalURL.$token;
				header("Location: ".$PaypalURL);
			} else {
				//Redirecting to APIError.php to display errors.
				flashMessage(getLang('ErrorConnectingToPaypal'), MSG_ERROR, 'cart.php');

				$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment',  $this->GetName()), GetLang('ErrorConnectingToPaypal'), $nvpArray['RESULT']." ".$nvpArray['RESPMSG']);

				$location = $GLOBALS['ShopPath']."/cart.php";
				header("Location: $location");
			}
		}
コード例 #23
0
	private function PurchaseGiftCertificate($errors = array())
	{

		// Coming back to this page with one or more errors?
		$GLOBALS['HideErrorMessage'] = 'none';
		if(is_array($errors)) {
			$errors = implode("<br />", $errors);
		}
		if($errors != "") {
			$GLOBALS['HideErrorMessage'] = '';
			$GLOBALS['ErrorMessage'] = $errors;
		}

		$editing = false;

		$GLOBALS['CartItemId'] = -1;

		$quote = getCustomerQuote();

		if(!$errors) {
			// Editing an existing cart item
			if(isset($_REQUEST['itemid'])) {
				$itemid = $_REQUEST['itemid'];
				if($quote->hasItem($itemid) &&
					$quote->getItemById($itemid)->getType() == PT_GIFTCERTIFICATE) {
						$item = $quote->getItemById($itemid);
						$_POST = array(
							'selected_amount' => $item->getPrice(),
							'certificate_amount' => convertPriceToCurrency($item->getPrice()),
							'to_name' => $item->getRecipientName(),
							'to_email' => $item->getRecipientEmail(),
							'from_name' => $item->getSenderName(),
							'from_email' => $item->getSenderEmail(),
							'message' => $item->getMessage(),
							'certificate_theme' => $item->getTheme()
						);
						$editing = true;
						$GLOBALS['CartItemId'] = $item->getId();
				}
			}
		}
		else {
			if(isset($_REQUEST['cartitemid'])) {
				$editing = true;
				$GLOBALS['CartItemId'] = isc_html_escape($_REQUEST['cartitemid']);
			}
		}

		if($editing == true) {
			$GLOBALS['SaveGiftCertificateButton'] = GetLang('UpdateCertificateCart');
			$GLOBALS['CertificateTitle'] = GetLang('UpdateGiftCertificate');
		}
		else {
			$GLOBALS['SaveGiftCertificateButton'] = GetLang('AddCertificateCart');
			$GLOBALS['CertificateTitle'] = GetLang('PurchaseAGiftCertificate');
		}

		if($editing == true || $errors) {
			$GLOBALS['AgreeChecked'] = "checked=\"checked\"";
		}

		// Can the user select from one or more predefined amounts?
		$GLOBALS['GiftCertificateAmountSelect'] = '';
		if(GetConfig('GiftCertificateCustomAmounts') == 0) {
			foreach(GetConfig('GiftCertificateAmounts') as $amount) {
				$displayAmount = CurrencyConvertFormatPrice($amount);
				$sel = '';
				if(isset($_POST['selected_amount']) && $_POST['selected_amount'] == $amount) {
					$sel = 'selected=\"selected\"';
				}
				$GLOBALS['GiftCertificateAmountSelect'] .= sprintf("<option value='%s' %s>%s</option>", $amount, $sel, $displayAmount);
			}
			$GLOBALS['HideGiftCertificateCustomAmount'] = "none";
		}

		// Can the user enter their own amount?
		else {
			if(isset($_POST['certificate_amount'])) {
				$GLOBALS['CustomCertificateAmount'] = isc_html_escape($_POST['certificate_amount']);
				$GLOBALS['CustomAmountChecked'] = 'checked="checked"';
			}

			$GLOBALS['HideGiftCertificateAmountSelect'] = "none";

			// Is there a minimum and maximum limit? Firstly convert them to our selected currency
			$GLOBALS['GiftCertificateMinimum'] = ConvertPriceToCurrency(GetConfig('GiftCertificateMinimum'));
			$GLOBALS['GiftCertificateMaximum'] = ConvertPriceToCurrency(GetConfig('GiftCertificateMaximum'));

			if(GetConfig('GiftCertificateMinimum') > 0 && GetConfig('GiftCertificateMaximum') > 0) {
				$GLOBALS['GiftCertificateRange'] = sprintf(GetLang('GiftCertificateValueBetween'), CurrencyConvertFormatPrice(GetConfig('GiftCertificateMinimum')), CurrencyConvertFormatPrice(GetConfig('GiftCertificateMaximum')));
			}
			else if(GetConfig('GiftCertificateMinimum')) {
				$GLOBALS['GiftCertificateRange'] = sprintf(GetLang('GiftCertificateValueGreaterThan'), CurrencyConvertFormatPrice(GetConfig('GiftCertificateMinimum')));
			}
			else if(GetConfig('GiftCertificateMaximum')) {
				$GLOBALS['GiftCertificateRange'] = sprintf(GetLang('GetCertificateValueLessThan'), CurrencyConvertFormatPrice(GetConfig('GiftCertificateMaximum')));
			}
		}

		// If there is an expiry date for gift certificates, we need to show it just so the user is aware
		if(GetConfig('GiftCertificateExpiry') > 0) {
			$days = GetConfig('GiftCertificateExpiry')/86400;
			if(($days % 365) == 0) {
				if(($days/365) == 1) {
					$GLOBALS['ExpiresAfter'] = "1 ".GetLang('YearLower');
				} else {
					$GLOBALS['ExpiresAfter'] = number_format($days/365)." ".GetLang('YearsLower');
				}
			}
			else if(($days % 30) == 0) {
				if($days/30 == 1) {
					$GLOBALS['ExpiresAfter'] = "1 ".GetLang('MonthLower');
				} else {
					$GLOBALS['ExpiresAfter'] = number_format($days/30)." ".GetLang('MonthsLower');
				}
			}
			else if(($days % 7) == 0) {
				if(($days/7) == 1) {
					$GLOBALS['ExpiresAfter'] = "1 ".GetLang('WeeksLower');
				} else {
					$GLOBALS['ExpiresAfter'] = number_format($days/7)." ".GetLang('WeeksLower');
				}
			}
			else {
				if($days == 1) {
					$GLOBALS['ExpiresAfter'] = "1 ".GetLang('DayLower');
				} else {
					$GLOBALS['ExpiresAfter'] = number_format($days)." ".GetLang('DaysLower');
				}
			}
		}

		if(isset($GLOBALS['ExpiresAfter'])) {
			$GLOBALS['GiftCertificateTerms'] = sprintf(GetLang('GiftCertificateTermsExpires'), $GLOBALS['ExpiresAfter']);
		}
		else {
			$GLOBALS['HideExpiryInfo'] = "none";
		}

		// Get a list of the gift certificate themes
		$themes = @scandir(APP_ROOT."/templates/__master/__gift_themes/");
		$enabledThemes = explode(",", GetConfig('GiftCertificateThemes'));

		$GLOBALS['GiftCertificateThemes'] = '';
		if(count($enabledThemes) == 1) {
			$GLOBALS['HideThemeSelect'] = "none";
		}
		foreach($enabledThemes as $theme) {
			// Just double check this theme still actually exists
			if(in_array($theme, $themes)) {
				$themeName = preg_replace('#\.html$#i', "", $theme);
				$sel = '';
				if((isset($_POST['certificate_theme']) && $_POST['certificate_theme'] == $theme) || count($enabledThemes) == 1) {
					$sel = 'checked="checked"';
					$GLOBALS['SelectedCertificateTheme'] = $theme;
				}
				$GLOBALS['GiftCertificateThemes'] .= sprintf('<label><input type="radio" class="themeCheck" name="certificate_theme" value="%s" %s /> %s</label><br />', $theme, $sel, $themeName);
			}
		}

		if(!GetConfig('GiftCertificateThemes')) {
			$GLOBALS['HideErrorMessage'] = '';
			$GLOBALS['ErrorMessage'] = GetLang('NoGiftCertificateThemes');
			$GLOBALS['HideGiftCertificateForm'] = "none";
		}

		// Do we need to pre-fill the to details with anything?
		if(isset($_POST['to_name'])) {
			$GLOBALS['CertificateTo'] = isc_html_escape($_POST['to_name']);
		}
		else {
			$GLOBALS['CertificateTo'] = '';
		}
		if(isset($_POST['to_email'])) {
			$GLOBALS['CertificateToEmail'] = isc_html_escape($_POST['to_email']);
		}
		else {
			$GLOBALS['CertifcateToEmail'] = '';
		}

		$customer = null;
		$GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');

		// From details
		if(isset($_POST['from_name'])) {
			$GLOBALS['CertificateFrom'] = isc_html_escape($_POST['from_name']);
		}
		else {
			$customer = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerInfo();
			if(is_array($customer)) {
				$GLOBALS['CertificateFrom'] = isc_html_escape($customer['custconfirstname'] . ' ' . $customer['custconlastname']);
			}
		}
		if(isset($_POST['from_email'])) {
			$GLOBALS['CertificateFromEmail'] = isc_html_escape($_POST['from_email']);
		}
		else {
			if($customer === null) {
				$customer = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerInfo();
			}
			if(is_array($customer)) {
				$GLOBALS['CertificateFromEmail'] = isc_html_escape($customer['custconemail']);
			}
		}

		if(isset($_POST['message'])) {
			$GLOBALS['CertificateMessage'] = isc_html_escape($_POST['message']);
		}

		$GLOBALS['GiftCertificatePreviewModalTitle'] = GetLang('GiftCertificatePreviewModalTitle');

		// Show the gift certificates main page
		$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(sprintf("%s - %s", GetConfig('StoreName'), GetLang('GiftCertificates')));
		$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("giftcertificates");
		$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
	}
コード例 #24
0
ファイル: SideCartContents.php プロジェクト: hungnv0789/vhtm
	public function SetPanelSettings()
	{
		$GLOBALS['SNIPPETS']['SideCartItems'] = '';

		// We check $_SESSION['QUOTE'] directly here as to not
		// instantiate the quote if it doesn't already exist.
		if(!isset($_SESSION['QUOTE']) && getCustomerQuote()->getNumItems() == 0) {
			$this->DontDisplay = true;
			return;
		}

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

		$quote = getCustomerQuote();
		$items = $quote->getItems();
		foreach($items as $item) {
			if($item->getProductId()) {
				$GLOBALS['ProductName'] = "<a href=\"".ProdLink($item->getName())."\">".isc_html_escape($item->getName())."</a>";
			}
			else {
				$GLOBALS['ProductName'] = isc_html_escape($item->getName());
			}

			// 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['ProductPrice'] = currencyConvertFormatPrice($item->getTotal($incTax));
			$GLOBALS['ProductQuantity'] = $item->getQuantity();
			$GLOBALS['SNIPPETS']['SideCartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCartItem");
		}

		$numItems = $quote->getNumItems();
		if($numItems == 1) {
			$GLOBALS['SideCartItemCount'] = GetLang('SideCartYouHave1Item');
		} else {
			$GLOBALS['SideCartItemCount'] = sprintf(GetLang('SideCartYouHaveXItems'), $numItems);
		}

		$total = $quote->getSubTotal($incTax);
		$GLOBALS['ISC_LANG']['SideCartTotalCost'] = sprintf(GetLang('SideCartTotalCost'), CurrencyConvertFormatPrice($total));

		// Go through all the checkout modules looking for one with a GetSidePanelCheckoutButton function defined
		$GLOBALS['AdditionalCheckoutButtons'] = '';
		$HideCheckout = false;
		foreach (GetAvailableModules('checkout', true, true) as $module) {
			if (method_exists($module['object'], 'GetSidePanelCheckoutButton')) {
				$GLOBALS['AdditionalCheckoutButtons'] .= $module['object']->GetSidePanelCheckoutButton();
			}

			if ($module['object']->disableNonCartCheckoutButtons) {
				$HideCheckout = true;
			}

		}

		if ($HideCheckout) {
			$GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = '';
		} else {
			require_once ISC_BASE_PATH.'/includes/display/CartHeader.php';

			$cartPanel = getClass('ISC_CARTHEADER_PANEL');
			$cartPanel -> insertOptimizerLinkScript();
			$GLOBALS['SNIPPETS']['SideCartContentsCheckoutLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('SideCartContentsCheckoutLink');
		}

	}
コード例 #25
0
		/**
		* Set Express Checkout step in Paypal Express checkout
		* it sends cart details to paypal and redirect customer to paypal login page.
		*
		*/
		private function SetExpressCheckout()
		{
			$currency = GetCurrencyCodeByID(GetConfig('DefaultCurrencyID'));

			$merchant = $this->GetMerchantSettings();

			$quote = getCustomerQuote();
			$amount = $quote->getGrandTotal();

			if($merchant['testmode'] == 'YES') {
				$transactionURL = $this->_testTransactionURL;
				$transactionURI = $this->_testTransactionURI;
				$PaypalExpressCheckoutURL = 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=';
			}
			else {
				$transactionURL = $this->_liveTransactionURL;
				$transactionURI = $this->_liveTransactionURI;
				$PaypalExpressCheckoutURL = 'https://www.paypal.com/webscr&cmd=_express-checkout&token=';
			}

			$pp_array = array(
				'METHOD'	=> 'SetExpressCheckout',
				'USER'		=> $merchant['username'],
				'PWD'		=> $merchant['password'],
				'SIGNATURE'	=> $merchant['signature'],
				'VERSION'	=> '53.0',
				'PAYMENTACTION'	=> $merchant['transactionType'],
				'AMT'		=> number_format($amount,2,'.',''),
				'CURRENCYCODE'	=> $currency,
				'PAYMENTACTION'	=> $merchant['transactionType'],
				'RETURNURL'	=> $GLOBALS['ShopPath']."/checkout.php?action=set_external_checkout&provider=paypalpaymentsprous",
				'CANCELURL'	=> $GLOBALS['ShopPath']."/cart.php",
				'NOSHIPPING'	=> 0,
				'NOTIFYURL'	=> $GLOBALS['ShopPath'].'/checkout.php?action=gateway_ping&provider='.$this->GetId(),
			);
			$paypal_query = http_build_query($pp_array);


			$result = $this->_ConnectToProvider($transactionURL, $transactionURI, $paypal_query);
			$nvpArray = $this->_DecodePaypalResult($result);
			//if data is sent to paypal successfully, a token for this transaction will return from paypal
			if(strtolower($nvpArray['ACK']) == 'success') {
				// Redirect to paypal.com here
				$token = $nvpArray["TOKEN"];
				$PayPalURL = $PaypalExpressCheckoutURL.$token;
				header("Location: ".$PayPalURL);
			} else {
				//Redirecting to APIError.php to display errors.
				$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment',  $this->GetName()), GetLang('ErrorConnectingToPaypal'), $nvpArray['L_ERRORCODE0']." ".$nvpArray['L_LONGMESSAGE0']);
				flashMessage(getLang('ErrorConnectingToPaypal'), MSG_ERROR, 'cart.php');
			}
		}