当前位置: 首页>>代码示例>>PHP>>正文


PHP GetCountryByName函数代码示例

本文整理汇总了PHP中GetCountryByName函数的典型用法代码示例。如果您正苦于以下问题:PHP GetCountryByName函数的具体用法?PHP GetCountryByName怎么用?PHP GetCountryByName使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetCountryByName函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveAddressFields

		/**
		 * Save the submitted shipping address form data
		 *
		 * Method will map and save all the shipping address data
		 *
		 * @access private
		 * @param array $fields The form fields to save
		 * @param int $customerId The customerId
		 * @param int $shippingId The optional shipping ID. Default is 0 (new record)
		 * @return mixed The new shipping ID on successful new record, TRUE if record successfully
		 *               updated, FALSE on error
		 */
		private function saveAddressFields($fields, $customerId, $shippingId=0)
		{
			if (!is_array($fields) || empty($fields) || !isId($customerId)) {
				return false;
			}

			$savedata = array(
				'shipcustomerid' => $customerId
			);

			if (isId($shippingId)) {
				$savedata['shipid'] = $shippingId;
			}

			/**
			 * Map the private data
			 */
			$country = $state = '';

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

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

				$savedata[$this->shippingMap[$privateId]] = $fields[$fieldId]->getValue();

				if (strtolower($privateId) == 'country') {
					$country = $fields[$fieldId]->getValue();
				} else if (strtolower($privateId) == 'state') {
					$state = $fields[$fieldId]->getValue();
				}
			}

			/**
			 * Find the country and state ID if we can
			 */
			$countryId = $stateId = 0;

			if ($country !== '') {
				$countryId = GetCountryByName($country);
			}

			if ($state !== '' && isId($countryId)) {
				$stateId = GetStateByName($state, $countryId);
			}

			$savedata['shipcountryid'] = (int)$countryId;
			$savedata['shipstateid'] = (int)$stateId;

			/**
			 * Save our custom (non private) fields if we are allowed
			 */
			if (gzte11(ISC_MEDIUMPRINT)) {

				/**
				 * Do we already have a form session ID for this address?
				 */
				$formSessionId = 0;
				if (isId($shippingId)) {
					$address = $this->shippingEntity->get($shippingId);
					if (is_array($address) && isset($address['shipformsessionid']) && isId($address['shipformsessionid'])) {
						$formSessionId = $address['shipformsessionid'];
					}
				}

				if (isId($formSessionId)) {
					$GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ADDRESS, true, $formSessionId);
				} else {
					$formSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ADDRESS);
					if (isId($formSessionId)) {
						$savedata['shipformsessionid'] = $formSessionId;
					}
				}
			}

			if (isId($shippingId)) {
				return $this->shippingEntity->edit($savedata);
			} else {
				return $this->shippingEntity->add($savedata);
			}
		}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:95,代码来源:class.customers.php

示例2: _ImportRecord

 /**
  * Imports an actual product record in to the database.
  *
  * @param array Array of record data
  */
 protected function _ImportRecord($record)
 {
     if (!$record['custconemail']) {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportCustomersMissingEmail');
         return;
     }
     if (!is_email_address($record['custconemail'])) {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportCustomersInvalidEmail');
         return;
     }
     $fillin = array('custconcompany', 'custconfirstname', 'custconlastname', 'custconphone');
     foreach ($fillin as $fillkey) {
         if (!isset($record[$fillkey])) {
             $record[$fillkey] = '';
         }
     }
     // Is there an existing customer with the same email?
     $customerId = 0;
     $existingFormSessionId = 0;
     $query = sprintf("select customerid from [|PREFIX|]customers where lower(custconemail)='%s'", $GLOBALS['ISC_CLASS_DB']->Quote(isc_strtolower($record['custconemail'])));
     $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
     if ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) {
         // Overriding existing products, set the product id
         if (isset($this->ImportSession['OverrideDuplicates']) && $this->ImportSession['OverrideDuplicates'] == 1) {
             $customerId = $row['customerid'];
             $this->ImportSession['Results']['Updates'][] = $record['custconfirstname'] . " " . $record['custconlastname'] . " (" . $record['custconemail'] . ")";
         } else {
             $this->ImportSession['Results']['Duplicates'][] = $record['custconfirstname'] . " " . $record['custconlastname'] . " (" . $record['custconemail'] . ")";
             return;
         }
         if (isId($row['custformsessionid'])) {
             $existingFormSessionId = $row['custformsessionid'];
         }
     }
     $customerData = array('company' => $record['custconcompany'], 'firstname' => $record['custconfirstname'], 'lastname' => $record['custconlastname'], 'email' => $record['custconemail'], 'phone' => $record['custconphone']);
     if (isset($record['custpassword']) && $record['custpassword'] !== '') {
         $customerData['password'] = $record['custpassword'];
     }
     if (isset($record['custstorecredit'])) {
         $customerData['storecredit'] = DefaultPriceFormat($record['custstorecredit']);
     }
     if (isId($customerId)) {
         $customerData['customerid'] = $customerId;
     }
     // Are we placing the customer in a customer group?
     $groupId = 0;
     if (!empty($record['custgroup'])) {
         static $customerGroups;
         $groupName = strtolower($record['custgroup']);
         if (isset($customerGroups[$groupName])) {
             $groupId = $customerGroups[$groupName];
         } else {
             $query = "\n\t\t\t\t\tSELECT customergroupid\n\t\t\t\t\tFROM [|PREFIX|]customer_groups\n\t\t\t\t\tWHERE LOWER(groupname)='" . $GLOBALS['ISC_CLASS_DB']->Quote($groupName) . "'\n\t\t\t\t";
             $groupId = $GLOBALS['ISC_CLASS_DB']->FetchOne($query, 'customergroupid');
             // Customer group doesn't exist, create it
             if (!$groupId) {
                 $newGroup = array('name' => $record['custgroup'], 'discount' => 0, 'isdefault' => 0, 'categoryaccesstype' => 'all');
                 $entity = new ISC_ENTITY_CUSTOMERGROUP();
                 $groupId = $entity->add($newGroup);
             }
             if ($groupId) {
                 $customerGroups[$groupName] = $groupId;
             }
         }
     }
     $customerData['customergroupid'] = $groupId;
     // Do we have a shipping address?
     $shippingData = array();
     if (isset($record['shipfullname']) || isset($record['shipfirstname']) || isset($record['shipaddress1']) || isset($record['shipaddress2']) || isset($record['shipcity']) || isset($record['shipstate']) || isset($record['shipzip']) || isset($record['shipcountry'])) {
         $fillin = array('shipaddress1', 'shipaddress2', 'shipcity', 'shipstate', 'shipzip', 'shipcountry');
         foreach ($fillin as $fillkey) {
             if (!isset($record[$fillkey])) {
                 $record[$fillkey] = '';
             }
         }
         $shippingData['shipfirstname'] = '';
         $shippingData['shiplastname'] = '';
         $shippingData['shipaddress1'] = $record['shipaddress1'];
         $shippingData['shipaddress2'] = $record['shipaddress2'];
         $shippingData['shipcity'] = $record['shipcity'];
         $shippingData['shipstate'] = $record['shipstate'];
         $shippingData['shipzip'] = $record['shipzip'];
         $shippingData['shipcountry'] = $record['shipcountry'];
         $shippingData['shipstateid'] = 0;
         $shippingData['shipcountryid'] = 0;
         $shippingData['shipdestination'] = '';
         // Find the country and state
         $shippingData['shipcountryid'] = (int) GetCountryByName($record['shipcountry']);
         if (!$shippingData['shipcountryid']) {
             $shippingData['shipcountryid'] = (int) GetCountryIdByISO2($record['shipcountry']);
         }
         // Still nothing? 0 for the shipping country ID
         if (!$shippingData['shipcountryid']) {
             $shippingData['shipcountryid'] = 0;
         }
//.........这里部分代码省略.........
开发者ID:nirvana-info,项目名称:old_bak,代码行数:101,代码来源:class.batch.importer_29_3.php

示例3: CreateAccountStep1

 /**
  *	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');
//.........这里部分代码省略.........
开发者ID:nirvana-info,项目名称:old_bak,代码行数:101,代码来源:class.customer.php

示例4: CommitOrder

 /**
  * Actually save a new order or an updated existing order in the database
  * after it's been validated.
  *
  * @param array An array of details about the order to save.
  * @param int The ID of the existing order if we're updating an order.
  * @return boolean True if successful, false if not.
  */
 private function CommitOrder($data, $orderId = 0)
 {
     $GLOBALS['ISC_CLASS_DB']->StartTransaction();
     /**
      * We need to find our billing/shipping details from the form fields first as it is
      * also used in creating the customer
      */
     $billingDetails = array();
     $shippingDetails = array();
     $billingFields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_BILLING, true);
     $shippingFields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_SHIPPING, true);
     $fields = $billingFields + $shippingFields;
     $addressMap = array('FirstName' => 'firstname', 'LastName' => 'lastname', 'CompanyName' => 'company', 'AddressLine1' => 'address1', 'AddressLine2' => 'address2', 'City' => 'city', 'State' => 'state', 'Zip' => 'zip', 'State' => 'state', 'Country' => 'country', 'Phone' => 'phone');
     foreach (array_keys($fields) as $fieldId) {
         $privateName = $fields[$fieldId]->record['formfieldprivateid'];
         if ($privateName == '' || !array_key_exists($privateName, $addressMap)) {
             continue;
         }
         if ($fields[$fieldId]->record['formfieldformid'] == FORMFIELDS_FORM_BILLING) {
             $detailsVar =& $billingDetails;
         } else {
             $detailsVar =& $shippingDetails;
         }
         /**
          * Find the country
          */
         if (isc_strtolower($privateName) == 'country') {
             $detailsVar['shipcountry'] = $fields[$fieldId]->getValue();
             $detailsVar['shipcountryid'] = GetCountryByName($fields[$fieldId]->getValue());
             if (!isId($detailsVar['shipcountryid'])) {
                 $detailsVar['shipcountryid'] = 0;
             }
             /**
              * Else find the state
              */
         } else {
             if (isc_strtolower($privateName) == 'state') {
                 $detailsVar['shipstate'] = $fields[$fieldId]->getValue();
                 $stateInfo = GetStateInfoByName($detailsVar['shipstate']);
                 if ($stateInfo && isId($stateInfo['stateid'])) {
                     $detailsVar['shipstateid'] = $stateInfo['stateid'];
                 } else {
                     $detailsVar['shipstateid'] = 0;
                 }
                 /**
                  * Else the rest
                  */
             } else {
                 $detailsVar['ship' . $addressMap[$privateName]] = $fields[$fieldId]->getValue();
             }
         }
     }
     // If we're creating an account for this customer, create it now
     if ($data['ordcustid'] == 0 && $data['customerType'] == 'new') {
         $customerData = array('email' => $data['custconemail'], 'password' => $data['custpassword'], 'firstname' => $billingDetails['shipfirstname'], 'lastname' => $billingDetails['shiplastname'], 'company' => $billingDetails['shipcompany'], 'phone' => $billingDetails['shipphone'], 'token' => GenerateCustomerToken(), 'customergroupid' => $data['custgroupid'], 'storecredit' => DefaultPriceFormat($data['custstorecredit']));
         /**
          * Save the customer custom fields
          */
         if (gzte11(ISC_MEDIUMPRINT)) {
             $formSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ACCOUNT);
             if (isId($formSessionId)) {
                 $customerData['custformsessionid'] = $formSessionId;
             }
         }
         $entity = new ISC_ENTITY_CUSTOMER();
         $data['ordcustid'] = $entity->add($customerData);
         if (!$data['ordcustid']) {
             $GLOBALS['ISC_CLASS_DB']->RollbackTransaction();
             return false;
         }
     }
     $orderSummary = $this->CalculateOrderSummary();
     $defaultCurrency = GetDefaultCurrency();
     $email = '';
     if (isset($data['custconemail']) && $data['customerType'] == 'new') {
         $email = $data['custconemail'];
     } else {
         if (isset($data['anonymousemail']) && $data['customerType'] == 'anonymous') {
             $email = $data['anonymousemail'];
         }
     }
     $newOrder = array('paymentmethod' => $data['orderpaymentmodule'], 'customerid' => $data['ordcustid'], 'billingaddress' => $billingDetails, 'ordbillemail' => $email, 'ordbillphone' => $billingDetails['shipphone'], 'geoipcountry' => $billingDetails['shipcountry'], 'geoipcountrycode' => GetCountryISO2ByName($billingDetails['shipcountry']), 'vendorid' => $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId(), 'giftcertificates' => $this->GetCartApi()->GetGiftCertificates(), 'shippingcost' => $orderSummary['shippingCost'], 'handlingcost' => $orderSummary['handlingCost'], 'pending_token' => GenerateOrderToken(), 'itemtotal' => $orderSummary['subtotal'], 'taxcost' => $orderSummary['taxCost'], 'taxrate' => $orderSummary['taxRate'], 'taxname' => $orderSummary['taxName'], 'giftcertificateamount' => $orderSummary['giftCertificateTotal'], 'gatewayamount' => $orderSummary['adjustedTotalCost'], 'totalincludestax' => $orderSummary['taxIncluded'], 'shippingprovider' => $orderSummary['shippingMethod'], 'shippingmodule' => $orderSummary['shippingModule'], 'totalcost' => $orderSummary['total'], 'ordstatus' => 0, 'isdigitalorder' => (int) $this->GetCartApi()->AllProductsInCartAreIntangible(), 'currencyid' => $defaultCurrency['currencyid'], 'currencyexchangerate' => 0, 'ordercomments' => @$data['ordcustmessage'], 'ordnotes' => @$data['ordnotes'], 'products' => $this->GetCartApi()->GetProductsInCart(), 'ordtrackingno' => $data['ordtrackingno']);
     if (isset($data['ordbillsaveAddress'])) {
         $newOrder['billingaddress']['saveAddress'] = 1;
         if (gzte11(ISC_MEDIUMPRINT)) {
             $newOrder['billingaddress']['shipformsessionid'] = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_BILLING);
         }
     }
     if ($newOrder['paymentmethod'] == 'manual') {
         $newOrder['paymentmethodname'] = GetLang('ManualPayment');
     } else {
         if ($newOrder['paymentmethod'] == 'giftcertificate') {
//.........这里部分代码省略.........
开发者ID:nirvana-info,项目名称:old_bak,代码行数:101,代码来源:class.offers_jun24.php

示例5: CommitOrder

 /**
  * Actually save a new order or an updated existing order in the database
  * after it's been validated.
  *
  * @param array An array of details about the order to save.
  * @param int The ID of the existing order if we're updating an order.
  * @return boolean True if successful, false if not.
  */
 private function CommitOrder($data, $orderId = 0)
 {
     $GLOBALS['ISC_CLASS_DB']->StartTransaction();
     /**
      * We need to find our billing/shipping details from the form fields first as it is
      * also used in creating the customer
      */
     $billingDetails = array();
     $shippingDetails = array();
     $billingFields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_BILLING, true);
     $shippingFields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_SHIPPING, true);
     $fields = $billingFields + $shippingFields;
     $addressMap = array('FirstName' => 'firstname', 'LastName' => 'lastname', 'CompanyName' => 'company', 'AddressLine1' => 'address1', 'AddressLine2' => 'address2', 'City' => 'city', 'State' => 'state', 'Zip' => 'zip', 'State' => 'state', 'Country' => 'country', 'Phone' => 'phone');
     foreach (array_keys($fields) as $fieldId) {
         $privateName = $fields[$fieldId]->record['formfieldprivateid'];
         if ($privateName == '' || !array_key_exists($privateName, $addressMap)) {
             continue;
         }
         if ($fields[$fieldId]->record['formfieldformid'] == FORMFIELDS_FORM_BILLING) {
             $detailsVar =& $billingDetails;
         } else {
             $detailsVar =& $shippingDetails;
         }
         /**
          * Find the country
          */
         if (isc_strtolower($privateName) == 'country') {
             $detailsVar['shipcountry'] = $fields[$fieldId]->getValue();
             $detailsVar['shipcountryid'] = GetCountryByName($fields[$fieldId]->getValue());
             if (!isId($detailsVar['shipcountryid'])) {
                 $detailsVar['shipcountryid'] = 0;
             }
             /**
              * Else find the state
              */
         } else {
             if (isc_strtolower($privateName) == 'state') {
                 $detailsVar['shipstate'] = $fields[$fieldId]->getValue();
                 $stateInfo = GetStateInfoByName($detailsVar['shipstate']);
                 if ($stateInfo && isId($stateInfo['stateid'])) {
                     $detailsVar['shipstateid'] = $stateInfo['stateid'];
                 } else {
                     $detailsVar['shipstateid'] = 0;
                 }
                 /**
                  * Else the rest
                  */
             } else {
                 $detailsVar['ship' . $addressMap[$privateName]] = $fields[$fieldId]->getValue();
             }
         }
     }
     // If we're creating an account for this customer, create it now
     if ($data['ordcustid'] == 0 && $data['customerType'] == 'new') {
         $customerData = array('email' => $data['custconemail'], 'password' => $data['custpassword'], 'firstname' => $billingDetails['shipfirstname'], 'lastname' => $billingDetails['shiplastname'], 'company' => $billingDetails['shipcompany'], 'phone' => $billingDetails['shipphone'], 'token' => GenerateCustomerToken(), 'customergroupid' => $data['custgroupid']);
         $GLOBALS['CusFirstname'] = $billingDetails['shipfirstname'];
         # Baskaran
         /* Added the store credit as seperate as it may be disabled while add/edit order - vikas  */
         if (isset($data['custstorecredit'])) {
             $customerData['storecredit'] = DefaultPriceFormat($data['custstorecredit']);
         }
         /**
          * Save the customer custom fields
          */
         if (gzte11(ISC_MEDIUMPRINT)) {
             $formSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ACCOUNT);
             if (isId($formSessionId)) {
                 $customerData['custformsessionid'] = $formSessionId;
             }
         }
         $entity = new ISC_ENTITY_CUSTOMER();
         $data['ordcustid'] = $entity->add($customerData);
         if (!$data['ordcustid']) {
             $GLOBALS['ISC_CLASS_DB']->RollbackTransaction();
             return false;
         }
     }
     //2010-11-08 Ronnie add When calculating the ship infomation corresponding to no
     $GLOBALS['BCK_shipcountryid'] = $detailsVar['shipcountry'];
     $GLOBALS['BCK_shipstateid'] = $detailsVar['shipstate'];
     if ($GLOBALS['BCK_shipstateid'] == '') {
         $GLOBALS['BCK_shipcountryid'] = $billingDetails['shipcountry'];
         $GLOBALS['BCK_shipstateid'] = $billingDetails['shipstate'];
     }
     foreach ($this->GetCartApi()->GetProductsInCart() as $rowId => $product) {
         if (!isset($product['exists_order_coupon']) && isset($product['discount'])) {
             // Now workout the discount amount
             if ($product['coupontype'] == 0) {
                 // It's a dollar discount
                 $newPrice = $product['product_price'] - $product['discount'];
             } else {
                 // It's a percentage discount
//.........这里部分代码省略.........
开发者ID:nirvana-info,项目名称:old_bak,代码行数:101,代码来源:class.orders.php

示例6: SetPanelSettings

	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);
//.........这里部分代码省略.........
开发者ID:hungnv0789,项目名称:vhtm,代码行数:101,代码来源:CheckoutNewAddressForm.php

示例7: populateQuoteAddressFormFields

		/**
		* 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;
		}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:86,代码来源:class.orders.php

示例8: GetExpressCheckoutAddressData

 /**
  * Validate an incoming shipping or billing address checking for missing fields and showing error
  * messages where necessary. Returns a structured address array if the passed address is valid.
  *
  * @param string The type of address to validate (billing or shipping)
  * @return array An array of information about the address if valid.
  */
 private function GetExpressCheckoutAddressData($type)
 {
     // Check to see if our state is required for the selected country
     $stateRequired = false;
     if (isset($_POST[$type . '_country']) && isId($_POST[$type . '_country']) && (!isset($_POST[$type . '_state']) || !$_POST[$type . '_state'])) {
         $query = $GLOBALS['ISC_CLASS_DB']->Query("SELECT COUNT(*) AS Total FROM [|PREFIX|]country_states WHERE statecountry='" . (int) $_POST[$type . '_country'] . "'");
         if (($total = $GLOBALS['ISC_CLASS_DB']->FetchOne($query, 'Total')) > 0) {
             $stateRequired = true;
         }
     }
     $addressVars = array('shipfirstname' => array('field' => $type . '_FirstName', 'required' => true, 'message' => GetLang('EnterShippingFirstName')), 'shiplastname' => array('field' => $type . '_LastName', 'required' => true, 'message' => GetLang('EnterShippingLastName')), 'shipcompany' => array('field' => $type . '_CompanyName', 'required' => false), 'shipaddress1' => array('field' => $type . '_AddressLine1', 'required' => true, 'message' => GetLang('EnterShippingAddress')), 'shipaddress2' => array('field' => $type . '_AddressLine2', 'required' => false), 'shipcity' => array('field' => $type . '_City', 'required' => true, 'message' => GetLang('EnterShippingCity')), 'shipstate' => array('field' => $type . '_State', 'required' => $stateRequired, 'message' => GetLang('EnterShippingState')), 'shipzip' => array('field' => $type . '_Zip', 'required' => true, 'message' => GetLang('EnterShippingZip')), 'shipcountry' => array('field' => $type . '_Country', 'required' => true, 'message' => GetLang('EnterShippingCountry')), 'shipphone' => array('field' => $type . '_Phone', 'required' => true, 'message' => GetLang('EnterShippingPhone')));
     if ($type == 'billing' && !CustomerIsSignedIn()) {
         $addressVars['shipemail'] = array('field' => 'billing_EmailAddress', 'required' => true, 'message' => GetLang('AccountEnterValidEmail'));
     }
     $addressData = array();
     $step = ucfirst($type) . 'Address';
     foreach ($addressVars as $field => $fieldInfo) {
         $postField = $fieldInfo['field'];
         // If this field is required and it hasn't been passed then we need to spit out an error
         if ($fieldInfo['required'] == true && (!isset($_POST[$postField]) || !$_POST[$postField])) {
             $tags[] = $this->MakeXMLTag('status', 0);
             $tags[] = $this->MakeXMLTag('step', $step);
             $tags[] = $this->MakeXMLTag('focus', '#' . $postField);
             $tags[] = $this->MakeXMLTag('message', $fieldInfo['message']);
             $this->SendXMLHeader();
             $this->SendXMLResponse($tags);
             exit;
         }
         // If the state field, we also need to get the ID of the state and save it too
         if ($field == 'shipstate') {
             $stateInfo = GetStateInfoByName($_POST[$postField]);
             $addressData['shipstate'] = $_POST[$postField];
             if ($stateInfo) {
                 $addressData['shipstateid'] = $stateInfo['stateid'];
             } else {
                 $addressData['shipstateid'] = 0;
             }
             continue;
         } else {
             if ($field == 'shipcountry') {
                 $addressData['shipcountry'] = $_POST[$postField];
                 $addressData['shipcountryid'] = GetCountryByName($_POST[$postField]);
                 if (!isId($addressData['shipcountryid'])) {
                     $addressData['shipcountryid'] = 0;
                 }
                 continue;
             }
         }
         $addressData[$field] = $_POST[$postField];
     }
     $addressData['shipdestination'] = 'residential';
     // OK, we've got everything we want, we can just return it now
     return $addressData;
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:61,代码来源:class.remote.php

示例9: GetCountryIdByName

/**
 *	Return the name of a country from its ID
 */
function GetCountryIdByName($country)
{
    return GetCountryByName($country);
}
开发者ID:nirvana-info,项目名称:old_bak,代码行数:7,代码来源:shipping_24_2.php

示例10: ValidateGuestCheckoutAddress

	/**
	 * 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;
			}
//.........这里部分代码省略.........
开发者ID:hungnv0789,项目名称:vhtm,代码行数:101,代码来源:class.checkout.php

示例11: ParseAddress

	private function ParseAddress($record, $customerId, $index = '')
	{
		$shippingData = array();

		$fillin = array('shipaddress1', 'shipaddress2', 'shipcity', 'shipstate', 'shipzip', 'shipcountry');
		foreach ($fillin as $fillkey) {
			if (!isset($record[$fillkey . $index])) {
				$record[$fillkey . $index] = '';
			}
		}

		if (isId($customerId)) {
			$shippingData["shipcustomerid"] = $customerId;
		}

		$shippingData['shipid'] = 0;
		if (!empty($record['shipid' . $index])) {
			$shippingData['shipid'] = $record['shipid' . $index];
		}

		$shippingData['shipfirstname'] = $record['shipfirstname' . $index];
		$shippingData['shiplastname'] = $record['shiplastname' . $index];
		$shippingData['shipaddress1'] = $record['shipaddress1' . $index];
		$shippingData['shipaddress2'] = $record['shipaddress2' . $index];
		$shippingData['shipcity'] = $record['shipcity' . $index];
		$shippingData['shipstate'] = $record['shipstate' . $index];
		$shippingData['shipzip'] = $record['shipzip' . $index];
		$shippingData['shipcountry'] = $record['shipcountry' . $index];
		$shippingData['shipstateid'] = 0;
		$shippingData['shipcountryid'] = 0;
		$shippingData['shipdestination'] = '';

		// Find the country and state
		$shippingData['shipcountryid'] = (int)GetCountryByName($record['shipcountry' . $index]);
		if(!$shippingData['shipcountryid']) {
			$shippingData['shipcountryid'] = (int)GetCountryIdByISO2($record['shipcountry' . $index]);
		}

		// Still nothing? 0 for the shipping country ID
		if(!$shippingData['shipcountryid']) {
			$shippingData['shipcountryid'] = 0;
		}

		if(isset($record['shipstate' . $index])) {
			$shippingData['shipstateid'] = GetStateByName($record['shipstate' . $index], $shippingData['shipcountryid']);
		}

		// Still nothing? 0 for the shipping state ID
		if(!$shippingData['shipstateid']) {
			$shippingData['shipstateid'] = 0;
		}

		if(!isset($record['shipphone' . $index]) && isset($record['custconphone' . $index])) {
			$shippingData['shipphone'] = $record['custconphone' . $index];
		}
		else {
			$shippingData['shipphone'] = $record['shipphone' . $index];
		}

		/**
		 * Handle any of the address custom fields that we might have
		 */
		if (!empty($this->customFields) && array_key_exists('custom', $record)) {
			$shippingData['shipformsessionid'] = $this->_importCustomFormfields(FORMFIELDS_FORM_ADDRESS, $record['custom' . $index]);

			if (!isId($shippingData['shipformsessionid'])) {
				unset($shippingData['shipformsessionid']);
			}
		}

		return $shippingData;
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:72,代码来源:customers.php

示例12: ValidateGuestCheckoutAddress

 /**
  * 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)
 {
     $errors = array();
     $addressVars = array('shipfirstname' => array('field' => $type . '_FirstName', 'required' => true, 'message' => GetLang('EnterShippingFirstName')), 'shiplastname' => array('field' => $type . '_LastName', 'required' => true, 'message' => GetLang('EnterShippingLastName')), 'shipcompany' => array('field' => $type . '_CompanyName', 'required' => false), 'shipaddress1' => array('field' => $type . '_AddressLine1', 'required' => true, 'message' => GetLang('EnterShippingAddress')), 'shipaddress2' => array('field' => $type . '_AddressLine2', 'required' => false), 'shipcity' => array('field' => $type . '_City', 'required' => true, 'message' => GetLang('EnterShippingCity')), 'shipstate' => array('field' => $type . '_State', 'required' => true, 'message' => GetLang('EnterShippingState')), 'shipzip' => array('field' => $type . '_Zip', 'required' => true, 'message' => GetLang('EnterShippingZip')), 'shipcountry' => array('field' => $type . '_Country', 'required' => true, 'message' => GetLang('EnterShippingCountry')));
     if ($type == 'billing' && !CustomerIsSignedIn()) {
         if (!isset($_POST['billing_EmailAddress']) || !is_email_address($_POST['billing_EmailAddress'])) {
             $errors[] = GetLang('AccountEnterValidEmail');
             return false;
         }
         $_POST['shipemail'] = $_POST['billing_EmailAddress'];
         // Check that this email address isn't already in use by a customer
         $customer = GetClass('ISC_CUSTOMER');
         if ($customer->AccountWithEmailAlreadyExists($_POST['shipemail'])) {
             $errors[] = sprintf(GetLang('CheckoutEmailAddressInUse'), GetConfig('ShopPath') . '/login.php');
             return false;
         }
     }
     $addressData = array();
     foreach ($addressVars as $field => $fieldInfo) {
         $postField = $fieldInfo['field'];
         // If this field is required and it hasn't been passed then we need to spit out an error
         if ($fieldInfo['required'] == true && (!isset($_POST[$postField]) || $_POST[$postField] == '')) {
             $errors[] = $fieldInfo['message'];
             return false;
         }
         // If the state field, we also need to get the ID of the state and save it too
         if ($field == 'shipstate') {
             $addressData['shipstate'] = $_POST[$type . '_State'];
             $addressData['shipstateid'] = 0;
             $stateInfo = GetStateInfoByName($_POST[$type . '_State']);
             if ($stateInfo) {
                 $addressData['shipstateid'] = $stateInfo['stateid'];
             }
             continue;
         } else {
             if ($field == 'shipcountry') {
                 $addressData['shipcountry'] = $_POST[$postField];
                 $addressData['shipcountryid'] = GetCountryByName($_POST[$postField]);
                 continue;
             }
         }
         $addressData[$field] = $_POST[$postField];
     }
     $addressData['shipdestination'] = 'residential';
     // OK, we've got everything we want, we can just return it now
     return $addressData;
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:54,代码来源:class.finalizeoffer.php

示例13: parseFieldData

 /**
  * Parse the submitted field data into an associative array
  *
  * Method will parse the submitted field data and convert it into an associative array
  * that resembles the shipping_addresses table structure
  *
  * @access private
  * @param array $fields The field list to parse from
  * @param int $formSessionId The optional form session ID
  * @return array The parsed array on success, FALSE on failure
  */
 private function parseFieldData($fields, $formSessionId = '')
 {
     if (!is_array($fields)) {
         return false;
     }
     $fieldMap = array('FirstName' => 'firstname', 'LastName' => 'lastname', 'CompanyName' => 'company', 'AddressLine1' => 'address1', 'AddressLine2' => 'address2', 'City' => 'city', 'State' => 'state', 'Country' => 'country', 'Zip' => 'zip', 'Phone' => 'phone');
     $savedata = array();
     $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']];
         $savedata[$key] = isc_html_escape($fields[$fieldId]->getValue());
         if ($key == 'shipcountry') {
             $countryFieldId = $fieldId;
         } else {
             if ($key == 'shipstate') {
                 $stateFieldId = $fieldId;
             }
         }
     }
     $savedata['shipcustomerid'] = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerId();
     /**
      * Fill in the country and state IDs
      */
     $savedata['shipcountryid'] = GetCountryByName($fields[$countryFieldId]->getValue());
     if (isId($savedata['shipcountryid'])) {
         $savedata['shipstateid'] = GetStateByName($fields[$stateFieldId]->getValue(), $savedata['shipcountryid']);
     } else {
         $savedata['shipstateid'] = 0;
     }
     /**
      * Now save the form session record
      */
     $formSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ADDRESS, true, $formSessionId);
     if (isId($formSessionId)) {
         $savedata['shipformsessionid'] = $formSessionId;
     }
     return $savedata;
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:53,代码来源:class.account.php

示例14: parseFieldData

/**
 * Parse the submitted field data into an associative array
 *
 * Method will parse the submitted field data and convert it into an associative array
 * that resembles the shipping_addresses table structure
 *
 * @access private
 * @param array $fields The field list to parse from
 * @param int $formSessionId The optional form session ID
 * @return array The parsed array on success, FALSE on failure
 */
function parseFieldData($fields, $formSessionId='')
{
	if (!is_array($fields)) {
		return false;
	}

	$fieldMap = getAddressFormMapping();
	$savedata = array();
	$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']];
		$savedata[$key] = $fields[$fieldId]->getValue();

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

	$savedata['shipcustomerid'] = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerId();

	/**
	 * Fill in the country and state IDs
	 */
	$savedata['shipcountryid'] = GetCountryByName($fields[$countryFieldId]->getValue());

	if (isId($savedata['shipcountryid'])) {
		$savedata['shipstateid'] = GetStateByName($fields[$stateFieldId]->getValue(), $savedata['shipcountryid']);
	} else {
		$savedata['shipstateid'] = 0;
	}

	/**
	 * Now save the form session record
	 */
	$formSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ADDRESS, true, $formSessionId);

	if (isId($formSessionId)) {
		$savedata['shipformsessionid'] = $formSessionId;
	}

	return $savedata;
}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:61,代码来源:addressvalidation.php


注:本文中的GetCountryByName函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。