Example #1
0
		/**
		 * Generate the shipping address form
		 *
		 * Method will generate the shipping address form based upon the section $section
		 *
		 * @access private
		 * @param string $section the different section to generate ('address' or 'custom')
		 * @param bool $preservePost TRUE to alse preserver the post, FALSE not to. Default is FALSE
		 * @param int $shippingId The optional shipping address ID. Default is 0 (no database record)
		 */
		private function generateAddressFields($section, $preservePost=false, $shippingId=0)
		{
			$section = strtolower($section);

			if ($section !== 'address' && $section !== 'custom') {
				return '';
			}

			$formSessionId = 0;
			$address = false;

			if (isId($shippingId) && !$preservePost) {
				$address = $this->shippingEntity->get($shippingId);

				if (!$address) {
					return '';
				}

				if ($section == 'custom' && isId($address['shipformsessionid'])) {
					$formSessionId = $address['shipformsessionid'];
				}
			}

			$fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ADDRESS, $preservePost, $formSessionId);

			if ($section == 'address') {

				/**
				 * Are we reading from the database?
				 */
				if (isId($shippingId) && !$preservePost) {
					foreach (array_keys($fields) as $fieldId) {
						$privateId = $fields[$fieldId]->record['formfieldprivateid'];

						if ($privateId == '' | !array_key_exists($privateId, $this->shippingMap) || !array_key_exists($this->shippingMap[$privateId], $address)) {
							continue;
						}

						$fields[$fieldId]->setValue($address[$this->shippingMap[$privateId]]);
					}
				}

				/**
				 * We'll need to add in the country and state options plus the country event
				 */
				$countryId = $stateId = 0;
				$selectedCountry = '';

				foreach (array_keys($fields) as $fieldId) {
					if (strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'country') {
						$fields[$fieldId]->setOptions(array_values(GetCountryListAsIdValuePairs()));
						$countryId = $fieldId;
						$selectedCountry = $fields[$fieldId]->getValue();
					} else if (strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'state') {
						$stateId = $fieldId;
					}
				}

				/**
				 * Do we have a selected country?
				 */
				if ($selectedCountry == '' && GetConfig('CompanyCountry') !== '') {
					$selectedCountry = GetConfig('CompanyCountry');
					$fields[$countryId]->setValue($selectedCountry);
				}

				/**
				 * Add the event
				 */
				$fields[$countryId]->addEventHandler('change', 'FormFieldEvent.SingleSelectPopulateStates', array('countryId' => $countryId, 'stateId' => $stateId));

				/**
				 * Now add in the state options if we can
				 */
				if ($selectedCountry !== '') {
					$countryRecordId = GetCountryByName($selectedCountry);
					if (isId($countryRecordId)) {
						$stateOptions = GetStateListAsIdValuePairs($countryRecordId);
						if (is_array($stateOptions) && !empty($stateOptions)) {
							$fields[$stateId]->setOptions($stateOptions);
						}
					}
				}
			}

			/**
			 * OK, now generate them all
			 */
			$html = '';

			foreach (array_keys($fields) as $fieldId) {
				$privateId = $fields[$fieldId]->record['formfieldprivateid'];

				if ($section == 'address' && $privateId == '') {
					continue;
				}

				if ($section == 'custom' && $privateId !== '') {
					continue;
				}

				/**
				 * We don't want these fields
				 */
				if ($section == 'address' && (strtolower($privateId) == 'savethisaddress' || strtolower($privateId) == 'shiptoaddress')) {
					continue;
				}

				$html .= $fields[$fieldId]->loadForFrontend() . "\n";
			}

			return $html;
		}
Example #2
0
 /**
  * Set up all of the template variables and predefined values for showing the form to edit an
  * existing order or create a new order. Will also set up the post variables as values if this
  * is a post request.
  *
  * @param array Optionally, if editing an order, the existing order to use for the default values.
  */
 private function SetupOrderManagementForm($order = array())
 {
     $GLOBLS['CurrentTab'] = 0;
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $postData = $_POST;
     } else {
         $postData = $order;
     }
     $orderFields = array('OrderBillFirstName' => 'ordbillfirstname', 'OrderBillLastName' => 'ordbilllastname', 'OrderBillCompany' => 'ordbillcompany', 'OrderBillPhone' => 'ordbillphone', 'OrderBillStreet1' => 'ordbillstreet1', 'OrderBillStreet2' => 'ordbillstreet2', 'OrderBillSuburb' => 'ordbillsuburb', 'OrderBillZip' => 'ordbillzip', 'OrderShipFirstName' => 'ordshipfirstname', 'OrderShipLastName' => 'ordshiplastname', 'OrderShipCompany' => 'ordshipcompany', 'OrderShipPhone' => 'ordshipphone', 'OrderShipStreet1' => 'ordshipstreet1', 'OrderShipStreet2' => 'ordshipstreet2', 'OrderShipSuburb' => 'ordshipsuburb', 'OrderShipZip' => 'ordshipzip', 'CustomerEmail' => 'custconemail', 'CustomerPassword' => 'custpassword', 'CustomerPassword2' => 'custpassword2', 'CustomerStoreCredit' => 'custstorecredit', 'CustomerGroup' => 'custgroupid', 'CustomerType' => 'customerType', 'OrderComments' => 'ordcustmessage', 'OrderNotes' => 'ordnotes', 'OrderId' => 'orderid', 'OrderTrackingNo' => 'ordtrackingno', 'AnonymousEmail' => 'anonymousemail', 'OrderBillEmail' => 'ordbillemail', 'OrderShipEmail' => 'ordshipemail');
     /* Added below condition for applying store credit permission - vikas */
     $loggeduser = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetUser();
     if ($loggeduser['userstorecreditperm'] == 0) {
         $GLOBALS['StoreCreditDisable'] = " disabled=\"\" ";
     }
     $GLOBALS['HideSelectedCustomer'] = 'display: none';
     $GLOBALS['HideCustomerSearch'] = '';
     $GLOBALS['HideAddressSelects'] = 'display: none';
     if (isset($postData['ordcustid']) && $postData['ordcustid'] > 0) {
         $GLOBALS['CurrentTab'] = 1;
         $GLOBALS['CustomerType'] = 'existing';
         $query = "\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM [|PREFIX|]customers WHERE customerid='" . (int) $postData['ordcustid'] . "'\n\t\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $existingCustomer = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         if ($existingCustomer['customerid']) {
             $GLOBALS['HideSelectedCustomer'] = '';
             $GLOBALS['HideCustomerSearch'] = 'display: none';
             $GLOBALS['HideHistoryLink'] = 'display: none';
             $GLOBALS['CustomerId'] = $existingCustomer['customerid'];
             $GLOBALS['CustomerFirstName'] = isc_html_escape($existingCustomer['custconfirstname']);
             $GLOBALS['CustomerLastName'] = isc_html_escape($existingCustomer['custconlastname']);
             $GLOBALS['CustomerPhone'] = '';
             if ($existingCustomer['custconphone']) {
                 $GLOBALS['CustomerPhone'] = isc_html_escape($existingCustomer['custconphone']) . '<br />';
             }
             $GLOBALS['CustomerEmail'] = '';
             if ($existingCustomer['custconemail']) {
                 $GLOBALS['CustomerEmail'] = '<a href="mailto:' . isc_html_escape($existingCustomer['custconemail']) . '">' . isc_html_escape($existingCustomer['custconemail']) . '</a><br />';
             }
             $GLOBALS['CustomerCompany'] = '';
             if ($existingCustomer['custconcompany']) {
                 $GLOBALS['CustomerCompany'] = isc_html_escape($existingCustomer['custconcompany']) . '<br />';
             }
             // Grab the addresses
             $addresses = $this->LoadCustomerAddresses($existingCustomer['customerid']);
             $GLOBALS['AddressJson'] = 'OrderManager.LoadInAddresses(' . isc_json_encode($addresses) . ');';
             if (!empty($addresses)) {
                 $GLOBALS['HideAddressSelects'] = '';
                 $GLOBALS['DisableAddressSelects'] = 'disabled="disabled"';
             }
             $GLOBALS['SelectedCustomer'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersCustomerSearchResult');
         }
         //alandy_2011-6-23 add.
         /*
         if($postData['orderid']>0){
          $query = "
         	   SELECT ordbillemail,ordshipemail
         	   FROM [|PREFIX|]orders WHERE ordcustid='".(int)$postData['ordcustid']."' and orderid=".$postData['orderid']."
            ";
            $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
            while($rs=$GLOBALS['ISC_CLASS_DB']->Fetch($result)){
            	  if(!empty($rs['ordbillemail'])){
            	   $GLOBALS['GuestCustomerEmail']=$rs['ordbillemail'];
            	  }else{
            	  	$GLOBALS['GuestCustomerEmail']=$rs['ordshipemail'];
            	  }
            }
         }
         */
     } else {
         if (isset($postData['ordcustid']) && $postData['ordcustid'] == 0) {
             if (!isset($postData['customerType'])) {
                 $GLOBALS['CurrentTab'] = 2;
             } else {
                 if ($postData['customerType'] == 'anonymous') {
                     $GLOBALS['CurrentTab'] = 2;
                 } else {
                     $GLOBALS['CurrenTab'] = 1;
                 }
             }
         }
     }
     /**
      * Customer and order custom fields
      */
     $GLOBALS['OrderCustomFormFieldsAccountFormId'] = FORMFIELDS_FORM_ACCOUNT;
     $GLOBALS['OrderCustomFormFieldsBillingFormId'] = FORMFIELDS_FORM_BILLING;
     $GLOBALS['OrderCustomFormFieldsShippingFormId'] = FORMFIELDS_FORM_SHIPPING;
     $GLOBALS['CustomFieldsAccountLeftColumn'] = '';
     $GLOBALS['CustomFieldsAccountRightColumn'] = '';
     $GLOBALS['CustomFieldsBillingColumn'] = '';
     $GLOBALS['CustomFieldsShippingColumn'] = '';
     $formIdx = array(FORMFIELDS_FORM_ACCOUNT, FORMFIELDS_FORM_BILLING, FORMFIELDS_FORM_SHIPPING);
     $fieldMap = array('FirstName' => 'firstname', 'LastName' => 'lastname', 'Company' => 'company', 'Phone' => 'phone', 'AddressLine1' => 'street1', 'AddressLine2' => 'street2', 'City' => 'suburb', 'Zip' => 'zip', 'Country' => 'country', 'State' => 'state');
     /**
      * Now process the forms
      */
     foreach ($formIdx as $formId) {
         $formSessionId = 0;
         if ($formId == FORMFIELDS_FORM_ACCOUNT) {
             /**
              * We are only using the real custom fields for the account section, so check here
              */
             if (!gzte11(ISC_MEDIUMPRINT)) {
                 continue;
             }
             if (isset($existingCustomer['custformsessionid'])) {
                 $formSessionId = $existingCustomer['custformsessionid'];
             }
         } else {
             if (isset($postData['ordformsessionid'])) {
                 $formSessionId = $postData['ordformsessionid'];
             }
         }
         /**
          * This part here gets all the existing fields
          */
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields($formId, true);
         } else {
             if (isId($formSessionId)) {
                 $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields($formId, false, $formSessionId);
             } else {
                 $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields($formId);
             }
         }
         /**
          * Get any selected country and state. This needs to be separate as we physically
          * print out each form field at a time so we need this information before hand
          */
         if ($formId !== FORMFIELDS_FORM_ACCOUNT) {
             $countryId = GetCountryIdByName(GetConfig('CompanyCountry'));
             $stateFieldId = 0;
             foreach (array_keys($fields) as $fieldId) {
                 if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'state') {
                     $stateFieldId = $fieldId;
                 } else {
                     if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'country') {
                         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                             $country = $fields[$fieldId]->getValue();
                         }
                         if ($formId == FORMFIELDS_FORM_BILLING) {
                             $country = @$order['ordbillcountry'];
                         } else {
                             $country = @$order['ordshipcountry'];
                         }
                         if (trim($country) !== '') {
                             $countryId = GetCountryIdByName($country);
                         }
                     }
                 }
             }
         }
         /**
          * Now we construct and build each form field
          */
         $column = 0;
         foreach (array_keys($fields) as $fieldId) {
             if ($formId == FORMFIELDS_FORM_ACCOUNT) {
                 if ($fields[$fieldId]->record['formfieldprivateid'] !== '' || !gzte11(ISC_MEDIUMPRINT)) {
                     continue;
                 }
                 $fieldHTML = $fields[$fieldId]->loadForFrontend();
                 if ($column % 2 > 0) {
                     $varname = 'CustomFieldsAccountLeftColumn';
                 } else {
                     $varname = 'CustomFieldsAccountRightColumn';
                 }
             } else {
                 /**
                  * We are using all the custom fields for the billing/shipping are, so check here
                  */
                 if (!gzte11(ISC_MEDIUMPRINT) && $fields[$fieldId]->record['formfieldprivateid'] == '') {
                     continue;
                 }
                 if ($formId == FORMFIELDS_FORM_BILLING) {
                     $varname = 'CustomFieldsBillingColumn';
                 } else {
                     $varname = 'CustomFieldsShippingColumn';
                 }
                 /**
                  * Set the value for the private fields if this is NOT a post
                  */
                 if ($_SERVER['REQUEST_METHOD'] !== 'POST' && $fields[$fieldId]->record['formfieldprivateid'] !== '') {
                     $key = @$fieldMap[$fields[$fieldId]->record['formfieldprivateid']];
                     if (trim($key) !== '') {
                         if ($formId == FORMFIELDS_FORM_BILLING) {
                             $key = 'ordbill' . $key;
                         } else {
                             $key = 'ordship' . $key;
                         }
                         if (array_key_exists($key, $order)) {
                             $fields[$fieldId]->setValue($order[$key]);
                         }
                     }
                 }
                 /**
                  * Add in any of the country/state lists if needed
                  */
                 if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'country') {
                     $fields[$fieldId]->setOptions(array_values(GetCountryListAsIdValuePairs()));
                     if ($fields[$fieldId]->getValue() == '') {
                         $fields[$fieldId]->setValue(GetConfig('CompanyCountry'));
                     }
                     $fields[$fieldId]->addEventHandler('change', 'FormFieldEvent.SingleSelectPopulateStates', array('countryId' => $fieldId, 'stateId' => $stateFieldId, 'inOrdersAdmin' => true));
                 } else {
                     if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'state' && isId($countryId)) {
                         $stateOptions = GetStateListAsIdValuePairs($countryId);
                         if (is_array($stateOptions) && !empty($stateOptions)) {
                             $fields[$fieldId]->setOptions($stateOptions);
                         }
                     }
                 }
                 /**
                  * We also do not what these fields
                  */
                 if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'savethisaddress' || isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'shiptoaddress') {
                     continue;
                 }
             }
             $GLOBALS[$varname] .= $fields[$fieldId]->loadForFrontend() . "\n";
             $column++;
         }
     }
     /**
      * Add this to generate our JS event script
      */
     $GLOBALS['FormFieldEventData'] = $GLOBALS['ISC_CLASS_FORM']->buildRequiredJS();
     /**
      * Do we display the customer custom fields?
      */
     if (!gzte11(ISC_MEDIUMPRINT)) {
         $GLOBALS['HideCustomFieldsAccountLeftColumn'] = 'none';
         $GLOBALS['HideCustomFieldsAccountRightColumn'] = 'none';
     } else {
         if ($GLOBALS['CustomFieldsAccountLeftColumn'] == '') {
             $GLOBALS['HideCustomFieldsAccountLeftColumn'] = 'none';
         }
         if ($GLOBALS['CustomFieldsAccountRightColumn'] == '') {
             $GLOBALS['HideCustomFieldsAccountRightColumn'] = 'none';
         }
     }
     $defaultValues = array('custgroupid' => 0, 'ordstatus' => 7);
     foreach ($defaultValues as $postField => $default) {
         if (!isset($postData[$postField])) {
             $postData[$postField] = $default;
         }
     }
     foreach ($orderFields as $templateField => $orderField) {
         if (!isset($postData[$orderField])) {
             $GLOBALS[$templateField] = '';
         } else {
             $GLOBALS[$templateField] = isc_html_escape($postData[$orderField]);
         }
     }
     if (empty($GLOBALS["AnonymousEmail"])) {
         $GLOBALS["AnonymousEmail"] = $postData['ordbillemail'];
     }
     if (isset($postData['ordbillsaveAddress'])) {
         $GLOBALS['OrderBillSaveAddress'] = 'checked="checked"';
     }
     if (isset($postData['ordshipsaveAddress'])) {
         $GLOBALS['OrderShipSaveAddress'] = 'checked="checked"';
     }
     if (isset($postData['shippingUseBilling'])) {
         $GLOBALS['ShippingUseBillingChecked'] = 'checked="checked"';
     }
     if (isset($postData['billingUseShipping'])) {
         $GLOBALS['BillingUseShippingChecked'] = 'checked="checked"';
     }
     $GLOBALS['OrderStatusOptions'] = $this->GetOrderStatusOptions($postData['ordstatus']);
     /*
      * To hide Pay and save button in edit mode -- Baskaran
      */
     if ($postData['ordstatus'] == '11') {
         $GLOBALS['PayandSaveDisplay'] = 'none';
     } else {
         $GLOBALS['PayandSaveDisplay'] = '';
     }
     $customerClass = GetClass('ISC_ADMIN_CUSTOMERS');
     $GLOBALS['CustomerGroupOptions'] = $customerClass->GetCustomerGroupsAsOptions($postData['custgroupid']);
     $GLOBALS['PaymentMethodsList'] = $this->GetPaymentProviderList($postData);
     if (!empty($order)) {
         $GLOBALS['HideEmailInvoice'] = 'display: none';
     } else {
         if (isset($postData['emailinvoice'])) {
             $GLOBALS['EmailInvoiceChecked'] = 'checked="checked"';
         }
     }
     $GLOBALS['Message'] = GetFlashMessageBoxes();
 }
Example #3
0
 /**
  *	Show the create account form. If $AlreadyExists is true then
  *	they've tried to create an account with an existing email address
  */
 private function CreateAccountStep1($Error = "")
 {
     $fillPostedValues = false;
     if ($Error != "") {
         $fillPostedValues = true;
         $GLOBALS['HideCreateAccountIntroMessage'] = "none";
     }
     $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT, $fillPostedValues);
     $fields += $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ADDRESS, $fillPostedValues);
     /**
      * Get any selected country and state
      */
     $countryName = GetConfig('CompanyCountry');
     $stateFieldId = 0;
     foreach (array_keys($fields) as $fieldId) {
         if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'state') {
             $stateFieldId = $fieldId;
         } else {
             if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'country' && $fields[$fieldId]->getValue() !== '') {
                 $countryName = $fields[$fieldId]->getValue();
             }
         }
     }
     /**
      * Compile the fields. Also set the country and state dropdowns while we are here
      */
     $GLOBALS['CreateAccountEmailPassword'] = '';
     $GLOBALS['CreateAccountDetails'] = '';
     $GLOBALS['CreateAccountAccountFormFieldID'] = FORMFIELDS_FORM_ACCOUNT;
     $GLOBALS['CreateAccountShippingFormFieldID'] = FORMFIELDS_FORM_ADDRESS;
     $compiledFields = null;
     $accountFields = array();
     $shippingFields = array();
     /**
      * These are used for error reporting
      */
     $emailAddress = '';
     $phoneNo = '';
     foreach (array_keys($fields) as $fieldId) {
         if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'emailaddress') {
             $emailAddress = $fields[$fieldId]->getValue();
         }
         if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'phone') {
             $phoneNo = $fields[$fieldId]->getValue();
         }
         if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'country') {
             $fields[$fieldId]->setOptions(array_values(GetCountryListAsIdValuePairs()));
             if ($countryName !== '') {
                 $fields[$fieldId]->setValue($countryName);
             }
             $fields[$fieldId]->addEventHandler('change', 'FormFieldEvent.SingleSelectPopulateStates', array('countryId' => $fieldId, 'stateId' => $stateFieldId));
         } else {
             if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'state' && $countryName !== '') {
                 $countryId = GetCountryByName($countryName);
                 $stateOptions = GetStateListAsIdValuePairs($countryId);
                 if (is_array($stateOptions) && !empty($stateOptions)) {
                     $fields[$fieldId]->setOptions($stateOptions);
                 }
             }
         }
         /**
          * We don't want this in the address (its only for single page checkout)
          */
         if (isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'savethisaddress' || isc_strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'shiptoaddress') {
             continue;
         }
         /**
          * If this is a password field then remove that 'leave blank' label
          */
         if ($fields[$fieldId]->getFieldType() == 'password') {
             $fields[$fieldId]->setLeaveBlankLabel(false);
         }
         /**
          * Separate out the fields
          */
         if ($fields[$fieldId]->record['formfieldformid'] == FORMFIELDS_FORM_ACCOUNT) {
             $GLOBALS['CreateAccountEmailPassword'] .= $fields[$fieldId]->loadForFrontend();
         } else {
             $GLOBALS['CreateAccountDetails'] .= $fields[$fieldId]->loadForFrontend();
         }
     }
     if ($Error == "already_exists") {
         // The email address is taken, they have to choose another one
         $GLOBALS['ErrorMessage'] = sprintf(GetLang('AccountEmailTaken'), isc_html_escape($emailAddress));
     } else {
         if ($Error == "invalid_number") {
             // The phone number is invalid
             $GLOBALS['ErrorMessage'] = sprintf(GetLang('AccountEnterValidPhone'), isc_html_escape($phoneNo));
         } else {
             if ($Error == "invalid_passwords") {
                 // The passwords do not match
                 $GLOBALS['ErrorMessage'] = GetLang('AccountPasswordsDontMatch');
             } else {
                 if ($Error == "database_error") {
                     // A database error occured while creating the account
                     $GLOBALS['ErrorMessage'] = GetLang('AccountInternalError');
                 } else {
                     if ($Error !== '') {
                         // Some other error while validating the field data. Should already be escaped
                         $GLOBALS['ErrorMessage'] = $Error;
                     } else {
                         $GLOBALS['HideCreateAccountErrorMessage'] = "none";
                     }
                 }
             }
         }
     }
     // Get the id of the customer
     $GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');
     $customer_id = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerId();
     /**
      * Load up any form field JS event data and any validation lang variables
      */
     $GLOBALS['FormFieldRequiredJS'] = $GLOBALS['ISC_CLASS_FORM']->buildRequiredJS();
     // Is captcha enabled?
     if (GetConfig('CaptchaEnabled') == false) {
         $GLOBALS['HideReviewCaptcha'] = "none";
     } else {
         // Generate the captcha image
         $GLOBALS['ISC_CLASS_CAPTCHA'] = GetClass('ISC_CAPTCHA');
         $GLOBALS['ISC_CLASS_CAPTCHA']->CreateSecret();
         $GLOBALS['CaptchaImage'] = $GLOBALS['ISC_CLASS_CAPTCHA']->ShowCaptcha();
     }
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(GetConfig('StoreName') . " - " . GetLang('CreateAccount'));
     $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("createaccount");
     $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
 }
	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();
	}
Example #5
0
		/**
		* This was inside addOrder, moved out for use by editing and for split-shipping allocation
		*
		* @param int $formId one of FORMFIELD_ form-type constants
		* @param ISC_QUOTE_ADDRESS $quoteAddress
		* @return array of field=>value variables suitable for setting as template data
		*/
		public function populateQuoteAddressFormFields($formId, ISC_QUOTE_ADDRESS $quoteAddress = null)
		{
			require_once ISC_BASE_PATH . '/lib/addressvalidation.php';

			if ($quoteAddress) {
				$quoteAddressFields = convertAddressArrayToFieldArray($quoteAddress->getAsArray());
			}

			$countryFieldId = 0;
			$stateFieldId = 0;
			$zipFieldId = 0;

			$formFields = $GLOBALS['ISC_CLASS_FORM']->getFormFields($formId);
			foreach($formFields as $fieldId => /** @var ISC_FORMFIELD_BASE */$field) {
				$field->setRequired(false);
				$formFieldPrivateId = $field->record['formfieldprivateid'];
				if($formFieldPrivateId && !gzte11(ISC_MEDIUMPRINT)) {
					unset($fieldId);
				}

				// for display purposes, pre-populate the form field with existing quote address info
				if ($quoteAddress && $quoteAddressFields) {
					if (!$formFieldPrivateId) {
						$customField = $quoteAddress->getCustomField($field->record['formfieldid']);
						if ($customField) {
							$field->setValue($customField['value']);
						}
					} else if (isset($quoteAddressFields[$formFieldPrivateId])) {
						$field->setValue($quoteAddressFields[$formFieldPrivateId], true);
					}
				}

				if($formFieldPrivateId == 'Country') {
					$field->setRequired(true);
					$countryFieldId = $fieldId;
				}
				else if($formFieldPrivateId == 'State') {
					$stateFieldId = $fieldId;
				}
				else if ($formFieldPrivateId == 'Zip') {
					$zipFieldId = $fieldId;
					$field->setRequired(true);
				}

				$GLOBALS['ISC_CLASS_FORM']->addFormFieldUsed($field);
			}

			// This is a massive hack, and a poorly designed feature. Seriously.
			if($countryFieldId) {
				$formFields[$countryFieldId]->setOptions(array_values(GetCountryListAsIdValuePairs()));
				if ($formFields[$countryFieldId]->getValue() == '') {
					$formFields[$countryFieldId]->setValue(GetConfig('CompanyCountry'));
				}

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

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

					if ($formFields[$stateFieldId]->getValue() == '') {
						$formFields[$stateFieldId]->setValue(getConfig('CompanyState'));
					}
				}
			}

			if ($zipFieldId && getConfig('CompanyZip') && $formFields[$zipFieldId]->getValue() == '') {
				$formFields[$zipFieldId]->setValue(getConfig('CompanyZip'));
			}

			return $formFields;
		}
Example #6
0
	/**
	 * Validate an incoming shipping/billing address.
	 *
	 * @param string The type of address to validate (billing or shipping)
	 * @param array An array of errors, passed by reference - if there are any
	 * @return array An array of information about the address if valid.
	 */
	public function ValidateGuestCheckoutAddress($type, &$errors)
	{
		$address = array();
		$errors = array();

		// for the billing address we need to validate the email address
		$email = '';
		if($type == 'billing' && !customerIsSignedIn()) {
			$emailField = $GLOBALS['ISC_CLASS_FORM']->getFormField(FORMFIELDS_FORM_ACCOUNT, '1', '', true);
			$email = $emailField->getValue();

			if($email == '' || !is_email_address($email)) {
				$errors[] = GetLang('AccountEnterValidEmail');
				return false;
			}

			// if guess checkout enabled and guess account creation on checkout is enabled and the entered email is already exist in the system
			// then we do email existance checking
			$customer = GetClass('ISC_CUSTOMER');
			if(getConfig('GuestCheckoutEnabled') && getConfig('GuestCheckoutCreateAccounts') && $customer->AccountWithEmailAlreadyExists($email)) {
				$errors[] = sprintf(GetLang('AccountEmailTaken'), isc_html_escape($email));
				return false;
			}
			$address['shipemail'] = $email;
		}

		require_once(ISC_BASE_PATH . '/lib/addressvalidation.php');

		// parse the form fields and validate them
		$errmsg = '';
		if($type == 'billing') {
			$formFieldType = FORMFIELDS_FORM_BILLING;
		}
		else {
			$formFieldType = FORMFIELDS_FORM_SHIPPING;
		}

		$fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields($formFieldType, true);

		$countryFieldId = 0;
		$stateFieldId = 0;
		foreach($fields as $fieldId => $formField) {
			if($formField->record['formfieldprivateid'] == 'Country') {
				$countryFieldId = $fieldId;
			}
			else if($formField->record['formfieldprivateid'] == 'State') {
				$stateFieldId = $fieldId;
			}
		}

		// Mark the state field as being optional if there are no states in the
		// selected country.
		if ($countryFieldId && $stateFieldId) {
			$countryId = GetCountryByName($fields[$countryFieldId]->getValue());
			$stateOptions = GetStateListAsIdValuePairs($countryId);

			if (is_array($stateOptions) && !empty($stateOptions)) {
				$fields[$stateFieldId]->setOptions($stateOptions);
			}
			else {
				$fields[$stateFieldId]->setRequired(false);
			}
		}

		if (!validateFieldData($fields, $errmsg)) {
			$errors[] = $errmsg;
			return false;
		}

		$fieldMap = array(
			'FirstName' => 'firstname',
			'LastName' => 'lastname',
			'CompanyName' => 'company',
			'AddressLine1' => 'address1',
			'AddressLine2' => 'address2',
			'City' => 'city',
			'State' => 'state',
			'Country' => 'country',
			'Zip' => 'zip',
			'Phone' => 'phone',
			'Email' => 'email',
		);

		foreach($fields as $fieldId => $formField) {
			// This isn't a built in field, so save the value for later handling
			if(!$formField->record['formfieldprivateid']) {
				$address['customFormFields'][$fieldId] = $formField->getValue();
				continue;
			}
			// Disregard any fields we don't know about
			else if(!isset($fieldMap[$formField->record['formfieldprivateid']])) {
				continue;
			}

			$key = 'ship' . $fieldMap[$formField->record['formfieldprivateid']];
			$address[$key] = $formField->getValue();
		}

		return $address;
	}
 /**
  * Generate the choose an address form for the express checkout for either a billing or shipping address.
  *
  * @param string The type of address fields to generate (either billing or shipping)
  * @return string The generated address form.
  */
 public function ExpressCheckoutChooseAddress($addressType)
 {
     $templateAddressType = ucfirst($addressType);
     $GLOBALS['AddressList'] = '';
     $GLOBALS['ISC_CLASS_MAKEAOFFER'] = GetClass('ISC_MAKEAOFFER');
     $GLOBALS['AddressType'] = $addressType;
     $GLOBALS['UpperAddressType'] = $templateAddressType;
     $GLOBALS['HideCreateAddress'] = 'display: none';
     $GLOBALS['HideChooseAddress'] = 'display: none';
     $GLOBALS['CreateAccountForm'] = '';
     $country_id = GetCountryIdByName(GetConfig('CompanyCountry'));
     $selectedCountry = GetConfig('CompanyCountry');
     $selectedState = 0;
     if ($addressType == 'shipping') {
         $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_SHIPPING);
         $formId = FORMFIELDS_FORM_SHIPPING;
     } else {
         if (!CustomerIsSignedIn()) {
             $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT);
             $fields += $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_BILLING);
             $formId = FORMFIELDS_FORM_ACCOUNT;
         } else {
             $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_BILLING);
             $formId = FORMFIELDS_FORM_BILLING;
         }
     }
     // If the customer isn't signed in, then by default we show the create form
     if (!CustomerIsSignedIn()) {
         $GLOBALS['HideCreateAddress'] = '';
         $address = array();
         if ($addressType == 'billing' && isset($_SESSION['CHECKOUT']['BILLING_ADDRESS'])) {
             $address = $_SESSION['CHECKOUT']['BILLING_ADDRESS'];
         } else {
             if ($addressType == 'shipping') {
                 if (isset($_SESSION['CHECKOUT']['SHIPPING_ADDRESS'])) {
                     $address = $_SESSION['CHECKOUT']['SHIPPING_ADDRESS'];
                 } else {
                     if (isset($_SESSION['CHECKOUT']['BILLING_ADDRESS'])) {
                         $address = $_SESSION['CHECKOUT']['BILLING_ADDRESS'];
                     }
                 }
             }
         }
         // if billing address is saved in session, use the session billing address to prefill the address form
         if (!empty($address)) {
             if (isset($address['shipcountry'])) {
                 $selectedCountry = $address['shipcountry'];
             }
             if (isset($address['shipstateid'])) {
                 $selectedState = $address['shipstateid'];
             }
             if (isset($address['shipcountryid'])) {
                 $country_id = $address['shipcountryid'];
             }
             $addressMap = array('EmailAddress' => 'shipemail', 'FirstName' => 'shipfirstname', 'LastName' => 'shiplastname', 'CompanyName' => 'shipcompany', 'AddressLine1' => 'shipaddress1', 'AddressLine2' => 'shipaddress2', 'City' => 'shipcity', 'State' => 'shipstate', 'Zip' => 'shipzip', 'Phone' => 'shipphone');
             $fieldMap = array();
             foreach (array_keys($fields) as $fieldId) {
                 if ($fields[$fieldId]->record['formfieldprivateid'] == '') {
                     continue;
                 }
                 $fieldMap[$fields[$fieldId]->record['formfieldprivateid']] = $fieldId;
             }
             foreach ($addressMap as $formField => $addressField) {
                 if (!isset($address[$addressField]) || !isset($fieldMap[$formField])) {
                     continue;
                 }
                 $fields[$fieldMap[$formField]]->SetValue($address[$addressField]);
             }
         }
         /**
          * Turn off the 'leave password blank' label for the passwords if we are not
          * logged in (creating a new account)
          */
         foreach (array_keys($fields) as $fieldId) {
             if ($fields[$fieldId]->getFieldType() == 'password') {
                 $fields[$fieldId]->setLeaveBlankLabel(false);
             }
         }
     } else {
         $GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');
         $shippingAddresses = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerShippingAddresses();
         // If the customer doesn't have any addresses, show the creation form
         if (empty($shippingAddresses)) {
             $GLOBALS['HideChooseAddress'] = 'display: none';
             $GLOBALS['HideCreateAddress'] = '';
         } else {
             $GLOBALS['HideChooseAddress'] = '';
             $addressMap = array('shipfullname', 'shipcompany', 'shipaddress1', 'shipaddress2', 'shipcity', 'shipstate', 'shipzip', 'shipcountry');
             foreach ($shippingAddresses as $address) {
                 $formattedAddress = '';
                 foreach ($addressMap as $field) {
                     if (!$address[$field]) {
                         continue;
                     }
                     $formattedAddress .= $address[$field] . ', ';
                 }
                 $GLOBALS['AddressSelected'] = '';
                 if (isset($_SESSION['CHECKOUT']['SelectAddress'])) {
                     if ($_SESSION['CHECKOUT']['SelectAddress'] == $address['shipid']) {
                         $GLOBALS['AddressSelected'] = ' selected="selected"';
                     }
                 } else {
                     if (!$GLOBALS['AddressList']) {
                         $GLOBALS['AddressSelected'] = ' selected="selected"';
                     }
                 }
                 $GLOBALS['AddressId'] = $address['shipid'];
                 $GLOBALS['AddressLine'] = isc_html_escape(trim($formattedAddress, ', '));
                 $GLOBALS['AddressList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ExpressCheckoutAddress');
             }
         }
     }
     if ($addressType == 'billing') {
         if (!CustomerIsSignedIn()) {
             $GLOBALS['CreateAccountForm'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ExpressCheckoutCreateAccount');
         }
         $GLOBALS['BillToAddressButton'] = GetLang('BillToThisAddress');
         if ($GLOBALS['ISC_CLASS_MAKEAOFFER']->api->AllProductsInCartAreIntangible()) {
             $GLOBALS['UseAddressTitle'] = GetLang('BillToThisAddress');
             $GLOBALS['HideShippingOptions'] = 'display: none';
         } else {
             $GLOBALS['UseAddressTitle'] = GetLang('BillAndShipToAddress');
         }
         $GLOBALS['UseExistingAddress'] = GetLang('UseExistingBillingAddress');
         $GLOBALS['AddNewAddress'] = GetLang('UseNewBillingAddress');
         $GLOBALS['ShipToBillingName'] = 'ship_to_billing';
     } else {
         $GLOBALS['BillToAddressButton'] = GetLang('ShipToThisAddress');
         $GLOBALS['UseAddressTitle'] = GetLang('ShipToThisAddress');
         $GLOBALS['UseExistingAddress'] = GetLang('UseExistingShippingAddress');
         $GLOBALS['AddNewAddress'] = GetLang('UseNewShippingAddress');
         $GLOBALS['ShipToBillingName'] = 'bill_to_shipping';
         $GLOBALS['HideShippingOptions'] = 'display: none';
     }
     // We need to loop here so we can get the field Id for the state
     $countryId = GetCountryIdByName($selectedCountry);
     $stateFieldId = 0;
     $countryFieldId = 0;
     foreach (array_keys($fields) as $fieldId) {
         if (strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'state') {
             $stateFieldId = $fieldId;
         } else {
             if (strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'country') {
                 $countryFieldId = $fieldId;
             }
         }
     }
     // Compile the fields. Also set the country and state dropdowns while we are here
     $GLOBALS['CompiledFormFields'] = '';
     foreach (array_keys($fields) as $fieldId) {
         if (strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'country') {
             $fields[$fieldId]->setOptions(GetCountryListAsIdValuePairs());
             if ($selectedCountry !== '') {
                 $fields[$fieldId]->setValue($selectedCountry);
             }
             /**
              * This is the event handler for changing the states where a country is selected
              */
             $fields[$fieldId]->addEventHandler('change', 'FormFieldEvent.SingleSelectPopulateStates', array('countryId' => $countryFieldId, 'stateId' => $stateFieldId));
         } else {
             if (strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'state' && isId($countryId)) {
                 $stateOptions = GetStateListAsIdValuePairs($countryId);
                 if (is_array($stateOptions) && !empty($stateOptions)) {
                     $fields[$fieldId]->setOptions($stateOptions);
                 }
                 /**
                  * Put an event handler on the 'ship to this address' so we can change the button value if
                  * this is the billing form, else remove it as it is the shipping form
                  */
             } else {
                 if (strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'shiptoaddress') {
                     if ($addressType == 'shipping') {
                         continue;
                     } else {
                         $fields[$fieldId]->addEventHandler('change', 'FormFieldEvent.CheckBoxShipToAddress');
                     }
                 }
             }
         }
         /**
          * Set the 'save address' and 'ship to' checkboxes to checked
          */
         if (strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'savethisaddress' || strtolower($fields[$fieldId]->record['formfieldprivateid']) == 'shiptoaddress') {
             $fields[$fieldId]->setValueByIndex(array(0));
         }
         $GLOBALS['CompiledFormFields'] .= $fields[$fieldId]->loadForFrontend() . "\n";
     }
     return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ExpressCheckoutChooseAddress');
 }
Example #8
0
		/**
		 * 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');
		}
Example #9
0
 /**
  * Map the address form fields
  *
  * Method will map each database record element in $data to the corresponding field
  * in $fields and set its value. Will also add in the country and state options
  *
  * @access private
  * @param array &$fields The referenced field list
  * @param array $data The optional database record to map against
  * @return bool TRUE if the mapping was successful, FALSE if not
  */
 private function mapFieldData(&$fields, $data = array())
 {
     if (!is_array($fields) || !is_array($data)) {
         return false;
     }
     $fieldMap = array('FirstName' => 'firstname', 'LastName' => 'lastname', 'CompanyName' => 'company', 'AddressLine1' => 'address1', 'AddressLine2' => 'address2', 'City' => 'city', 'State' => 'state', 'Country' => 'country', 'Zip' => 'zip', 'Phone' => 'phone');
     $countryFieldId = '';
     $stateFieldId = '';
     foreach (array_keys($fields) as $fieldId) {
         if (!array_key_exists($fields[$fieldId]->record['formfieldprivateid'], $fieldMap)) {
             continue;
         }
         $key = 'ship' . $fieldMap[$fields[$fieldId]->record['formfieldprivateid']];
         if (array_key_exists($key, $data)) {
             $fields[$fieldId]->setValue($data[$key]);
         }
         if ($key == 'shipcountry') {
             $countryFieldId = $fieldId;
         } else {
             if ($key == 'shipstate') {
                 $stateFieldId = $fieldId;
             }
         }
     }
     if ($countryFieldId) {
         $fields[$countryFieldId]->setOptions(array_values(GetCountryListAsIdValuePairs()));
         if ($fields[$countryFieldId]->getValue() == '') {
             $fields[$countryFieldId]->setValue(GetConfig('CompanyCountry'));
         }
         if (isId($stateFieldId)) {
             $fields[$countryFieldId]->addEventHandler('change', 'FormFieldEvent.SingleSelectPopulateStates', array('countryId' => $countryFieldId, 'stateId' => $stateFieldId));
             $countryId = GetCountryByName($fields[$countryFieldId]->getValue());
             $stateOptions = GetStateListAsIdValuePairs($countryId);
             if (is_array($stateOptions) && !empty($stateOptions)) {
                 $fields[$stateFieldId]->setOptions($stateOptions);
             }
         }
     }
     return true;
 }
Example #10
0
/**
 * Map the address form fields
 *
 * Method will map each database record element in $data to the corresponding field
 * in $fields and set its value. Will also add in the country and state options
 *
 * @access private
 * @param array &$fields The referenced field list
 * @param array $data The optional database record to map against
 * @return bool TRUE if the mapping was successful, FALSE if not
 */
function mapFieldData(&$fields, $data=array())
{
	if (!is_array($fields) || !is_array($data)) {
		return false;
	}

	$fieldMap = getAddressFormMapping();
	$countryFieldId = '';
	$stateFieldId = '';

	foreach (array_keys($fields) as $fieldId) {
		if (!array_key_exists($fields[$fieldId]->record['formfieldprivateid'], $fieldMap)) {
			continue;
		}

		$key = 'ship' . $fieldMap[$fields[$fieldId]->record['formfieldprivateid']];

		if (array_key_exists($key, $data)) {
			$fields[$fieldId]->setValue($data[$key]);
		}

		if ($key == 'shipcountry') {
			$countryFieldId = $fieldId;
		} else if ($key == 'shipstate') {
			$stateFieldId = $fieldId;
		}
	}

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

		if (isId($stateFieldId)) {
			$fields[$countryFieldId]->addEventHandler('change', 'FormFieldEvent.SingleSelectPopulateStates', array('countryId' => $countryFieldId, 'stateId' => $stateFieldId));

			$countryId = GetCountryByName($fields[$countryFieldId]->getValue());
			$stateOptions = GetStateListAsIdValuePairs($countryId);

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

	return true;
}