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


PHP GetStateByName函数代码示例

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


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

示例1: GetSalesTaxRate

 /**
  * Get the sales tax information regarding the passed billing & shipping details.
  *
  * @param mixed Either an integer with the billing address or an array of details about the address.
  * @param mixed Either an integer with the shipping address or an array of details about the address.
  * @return array Array of information containing the tax data. (name, rate, based on etc)
  */
 public function GetSalesTaxRate($billingAddress, $shippingAddress = 0)
 {
     // Setup the array which will be returned
     $taxData = array("tax_name" => "", "tax_rate" => 0, "tax_based_on" => "", "tax_id" => 0);
     // If tax is being applied globally, just return that
     if (GetConfig('TaxTypeSelected') == 2) {
         $basedOn = 'subtotal';
         if (GetConfig('DefaultTaxRateBasedOn')) {
             $basedOn = GetConfig('DefaultTaxRateBasedOn');
         }
         $taxData['tax_name'] = GetConfig('DefaultTaxRateName');
         $taxData['tax_rate'] = GetConfig('DefaultTaxRate');
         $taxData['tax_based_on'] = $basedOn;
         return $taxData;
     }
     $GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT');
     $countryIds = array();
     $stateIds = array();
     if (!is_array($billingAddress)) {
         $billingAddress = $GLOBALS['ISC_CLASS_ACCOUNT']->GetShippingAddress($billingAddress);
     }
     if (!is_array($shippingAddress) && $shippingAddress > 0) {
         $shippingAddress = $GLOBALS['ISC_CLASS_ACCOUNT']->GetShippingAddress($shippingAddress);
     }
     // A billing address is required for every order. If we don't have one then there's no point in proceeding
     if (!is_array($billingAddress)) {
         return $taxData;
     }
     if (!isset($billingAddress['shipcountryid'])) {
         $billingAddress['shipcountryid'] = GetCountryIdByName($billingAddress['shipcountry']);
     }
     if (!isset($billingAddress['shipstateid'])) {
         $billingAddress['shipstateid'] = GetStateByName($billingAddress['shipstate'], $billingAddress['shipcountryid']);
     }
     if (is_array($shippingAddress)) {
         if (!isset($shippingAddress['shipcountryid'])) {
             $shippingAddress['shipcountryid'] = GetCountryIdByName($shippingAddress['shipcountry']);
         }
         if (!isset($shippingAddress['shipstateid'])) {
             $shippingAddress['shipstateid'] = GetStateByName($shippingAddress['shipstate'], $shippingAddress['shipcountryid']);
         }
     }
     // Do we have a matching state based tax rule?
     if ($billingAddress['shipstateid'] || is_array($shippingAddress) && $shippingAddress['shipstateid']) {
         $query = "\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM [|PREFIX|]tax_rates\n\t\t\t\t\tWHERE (1=0\n\t\t\t\t";
         if ($billingAddress['shipstateid']) {
             $query .= " OR (taxaddress='billing' AND taxratecountry='" . (int) $billingAddress['shipcountryid'] . "' AND taxratestates LIKE '%%," . (int) $billingAddress['shipstateid'] . ",%%')";
         }
         if (is_array($shippingAddress) && $shippingAddress['shipstateid']) {
             $query .= " OR (taxaddress='shipping' AND taxratecountry='" . (int) $shippingAddress['shipcountryid'] . "' AND taxratestates LIKE '%%," . (int) $shippingAddress['shipstateid'] . ",%%')";
         }
         $query .= ") AND taxratestatus='1'";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         if (is_array($row)) {
             $taxData = array('tax_name' => $row['taxratename'], 'tax_rate' => $row['taxratepercent'], 'tax_based_on' => $row['taxratebasedon'], 'tax_id' => $row['taxrateid']);
             return $taxData;
         }
     }
     // Maybe we've got a matching country based rule
     $query = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM [|PREFIX|]tax_rates\n\t\t\t\tWHERE (1=0 OR (taxratecountry='" . (int) $billingAddress['shipcountryid'] . "' AND taxaddress='billing')\n\t\t\t";
     if (is_array($shippingAddress) && $shippingAddress['shipcountryid']) {
         $query .= " OR (taxratecountry='" . (int) $shippingAddress['shipcountryid'] . "' AND taxaddress='shipping')";
     }
     $query .= ") AND taxratestatus='1' AND taxratestates = ',0,'";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
     if (is_array($row)) {
         $taxData = array('tax_name' => $row['taxratename'], 'tax_rate' => $row['taxratepercent'], 'tax_based_on' => $row['taxratebasedon'], 'tax_id' => $row['taxrateid']);
         return $taxData;
     }
     // Otherwise, if we still have nothing, perhaps we have a rule that applies to all countries
     $query = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM [|PREFIX|]tax_rates\n\t\t\t\tWHERE taxratecountry='0' AND taxratestatus='1'\n\t\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
     if (is_array($row)) {
         $taxData = array('tax_name' => $row['taxratename'], 'tax_rate' => $row['taxratepercent'], 'tax_based_on' => $row['taxratebasedon'], 'tax_id' => $row['taxrateid']);
         return $taxData;
     }
     // Still here? Just return nothing!
     return $taxData;
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:89,代码来源:class.customer.php

示例2: 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

示例3: GetCountryStates

 /**
  * Display a list of states for a given country
  *
  * @return void
  **/
 private function GetCountryStates()
 {
     $country = $_REQUEST['c'];
     if (IsId($country)) {
         $countryId = $country;
     } else {
         $countryId = GetCountryIdByName($country);
     }
     if (isset($_REQUEST['s']) && GetStateByName($_REQUEST['s'], $countryId)) {
         $state = $_REQUEST['s'];
     } else {
         $state = '';
     }
     if (isset($_REQUEST['format']) && $_REQUEST['format'] == 'options') {
         echo GetStateListAsOptions($country, $state, false, '', '', false, true);
     } else {
         echo GetStateList((int) $country);
     }
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:24,代码来源:class.remote_dec04.php

示例4: _ImportRecord


//.........这里部分代码省略.........
         }
     }
     $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;
         }
         if (isset($record['shipstate'])) {
             $shippingData['shipstateid'] = GetStateByName($record['shipstate'], $shippingData['shipcountryid']);
         }
         // Still nothing? 0 for the shipping state ID
         if (!$shippingData['shipstateid']) {
             $shippingData['shipstateid'] = 0;
         }
         if (!isset($record['shipfullname']) || $record['shipfullname'] == "") {
             if (isset($record['shipfirstname']) && $record['shipfirstname'] != '') {
                 $shippingData['shipfirstname'] = $record['shipfirstname'];
             } else {
                 $shippingData['shipfirstname'] = $customerData['firstname'];
             }
             if (isset($record['shiplastname']) && $record['shiplastname'] != '') {
                 $shippingData['shiplastname'] = $record['shiplastname'];
             } else {
                 $shippingData['shiplastname'] = $customerData['lastname'];
             }
         }
         if (!isset($record['shipphone']) && isset($record['custconphone'])) {
             $shippingData['shipphone'] = $record['custconphone'];
         } else {
             $shippingData['shipphone'] = $record['shipphone'];
         }
         /**
          * 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']);
             if (!isId($shippingData['shipformsessionid'])) {
                 unset($shippingData['shipformsessionid']);
             }
         }
     }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:67,代码来源:class.batch.importer_29_3.php

示例5: OrderCalculateShipping

 /**
  * Calculate the shipping for an order that's being edited/created.
  */
 private function OrderCalculateShipping()
 {
     if (!isset($_REQUEST['orderSession'])) {
         exit;
     }
     $orderClass = GetClass('ISC_ADMIN_ORDERS');
     $orderClass->GetCartApi($_REQUEST['orderSession']);
     $cartProducts = $orderClass->GetCartApi()->GetProductsInCart();
     $cartClass = GetClass('ISC_CART');
     $address = array('shipzip' => @$_REQUEST['ordshipzip'], 'shipstate' => @$_REQUEST['ordshipstate'], 'shipcountry' => @$_REQUEST['ordshipcountry'], 'shipcountryid' => GetCountryIdByName(@$_REQUEST['ordshipcountry']));
     $address['shipstateid'] = GetStateByName($address['shipstate'], $address['shipcountryid']);
     $shippingMethods = $cartClass->GetAvailableShippingMethodsForProducts($address, $cartProducts, $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId());
     $orderClass->GetCartApi()->Set('SHIPPING_QUOTES', $shippingMethods);
     $existingShippingMethod = $orderClass->GetCartApi()->Get('SHIPPING_METHOD');
     $GLOBALS['ShippingMethods'] = '';
     foreach ($shippingMethods as $quoteId => $quote) {
         $checked = '';
         if (is_array($existingShippingMethod) && $quote['description'] == $existingShippingMethod['methodName']) {
             $hasChecked = true;
             $checked = 'checked="checked"';
         }
         $GLOBALS['MethodChecked'] = $checked;
         $GLOBALS['MethodName'] = isc_html_escape($quote['description']);
         $GLOBALS['MethodCost'] = FormatPrice($quote['price']);
         $GLOBALS['MethodId'] = $quoteId;
         $GLOBALS['ShippingMethods'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderShippingMethodChoice');
     }
     $GLOBALS['HideNoShipingMethods'] = 'display: none';
     if (!empty($shippingMethods)) {
         $GLOBALS['HideNoShippingMethods'] = '';
     }
     $existingOrder = $orderClass->GetCartApi()->Get('EXISTING_ORDER');
     $order = GetOrder($existingOrder);
     if ($existingOrder !== false && $order['ordshipmethod']) {
         $checked = '';
         if (!isset($hasChecked) && (!is_array($existingShippingMethod) || $order['ordshipmethod'] == $existingShippingMethod['methodName'])) {
             $checked = 'checked="checked"';
         }
         $GLOBALS['MethodChecked'] = $checked;
         $GLOBALS['MethodName'] = sprintf(GetLang('ExistingShippingMethod'), isc_html_escape($order['ordshipmethod']));
         $GLOBALS['MethodCost'] = FormatPrice($order['ordshipcost']);
         $GLOBALS['MethodId'] = 'existing';
         $GLOBALS['ShippingMethods'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderShippingMethodChoice') . $GLOBALS['ShippingMethods'];
     }
     $GLOBALS['CustomChecked'] = '';
     $GLOBALS['HideCustom'] = 'display: none';
     if (is_array($existingShippingMethod) && $existingShippingMethod['methodModule'] == 'custom') {
         $GLOBALS['CustomChecked'] = 'checked="checked"';
         $GLOBALS['CustomName'] = isc_html_escape($existingShippingMethod['methodName']);
         $GLOBALS['CustomPrice'] = FormatPrice($existingShippingMethod['methodCost'], false, false);
         $GLOBALS['HideCustom'] = '';
     }
     /* The below patch is added to check the custom shipping if no other shipping method exist - vikas - starts */
     if ($GLOBALS['ShippingMethods'] == "") {
         $GLOBALS['CustomChecked'] = 'checked="checked"';
         $GLOBALS['HideCustom'] = '';
     }
     // below custom name has been added as client told to make it readonly.
     if (!isset($GLOBALS['CustomName'])) {
         $GLOBALS['CustomName'] = "Custom";
     }
     /* - ends -*/
     echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderShippingMethodWindow');
     exit;
 }
开发者ID:nirvana-info,项目名称:old_bak,代码行数:68,代码来源:class.remote.orders_23_Jult_mj.php

示例6: getStateId

	/**
	 * Get the state ID
	 *
	 * Method will return the state ID if found
	 *
	 * @access protected
	 * @param string $stateName The state name / abbrevation
	 * @param int $countryId The country ID
	 * @param string $properStateName The referenced variable to set the proper state name if the record exists
	 * @return int The state ID on success, FALSE if not found
	 */
	protected function getStateId($stateName, $countryId, &$properStateName=null)
	{
		if (trim($stateName) == '' || !isId($countryId)) {
			return false;
		}

		$stateId = GetStateByName($stateName, $countryId);

		if (!isId($stateId)) {
			$stateId = GetStateByAbbrev($stateName, $countryId);
		}

		if (!isId($stateId)) {
			return false;
		}

		$properStateName = GetStateById($stateId);

		return $stateId;
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:31,代码来源:service.syncbase.php

示例7: GetStateID

		private function GetStateID($countryID, $stateName)
		{
			$stateID = GetStateByAbbrev($stateName, $countryID);

			if ($stateID) {
				return $stateID;
			}

			$stateID = GetStateByName($stateName, $countryID);
			if ($stateID) {
				return $stateID;
			}

			return 0;
		}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:15,代码来源:module.paypalexpress.php

示例8: 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

示例9: _handleAuctionCheckoutComplete


//.........这里部分代码省略.........

					// update the store inventory if necessary
					if (GetConfig('UpdateInventoryLevels') == 1) {
						DecreaseInventoryFromOrder($existingOrderId);
					}
					$this->log->LogSystemDebug('ebay', 'The status of the store order ('. $existingOrderId .') has been updated to: Awaiting Fulfillment');
				}
				return true;
			}

			$order['ShippingTotalCost'] = $order['ShippingInsuranceCost'] + $order['ShippingCost'];

			// Buyer's address information
			$addressMap = array(
				'Name',
				'CompanyName',
				'Street1',
				'Street2',
				'CityName',
				'PostalCode',
				'Country',
				'CountryName',
				'Phone',
				'StateOrProvince',
			);

			// Initialize the value, make sure it's not empty
			foreach ($addressMap as $key) {
				if (!isset($buyerInfoShippingAddress[$key])) {
					$buyerInfoShippingAddress[$key] = '';
				}
			}
			$buyerCountryId = GetCountryIdByISO2($buyerInfoShippingAddress['Country']);
			$buyerStateId = GetStateByName($buyerInfoShippingAddress['StateOrProvince'], $buyerCountryId);
			$buyerStateName = $buyerInfoShippingAddress['StateOrProvince'];
			if (!$buyerStateId) {
				$buyerStateId = GetStateByAbbrev($buyerInfoShippingAddress['StateOrProvince'], $buyerCountryId);
				$stateInfo = GetStateInfoById($buyerStateId);
				$buyerStateName = $stateInfo['statename'];
			}

			// Tokenize buyer's first and last name
			$nameTokens = explode(' ', $buyerInfoShippingAddress['Name']);
			$buyerFirstName = $nameTokens[0];
			$buyerLastName = '';
			if (!empty($nameTokens[1])) {
				$buyerLastName = $nameTokens[1];
			}

			$orderToken = generateOrderToken();

			// Preparing data to be inserted to orders table
			$newOrder = array(
				'ordtoken' => $orderToken,
				'orderpaymentmodule' => '',
				'orderpaymentmethod' => '',
				'orderpaymentmodule' => '',
				'extraInfo' => serialize(array()),
				'orddefaultcurrencyid' => $order['Currency']['currencyid'],
				'orddate' => time(),
				'ordlastmodified' => time(),
				'ordcurrencyid' => $order['Currency']['currencyid'],
				'ordcurrencyexchangerate' => 1,
				'ordipaddress' => GetIP(),
				'ordcustmessage' => '',
				'ordstatus' => $orderStatus,
开发者ID:hungnv0789,项目名称:vhtm,代码行数:67,代码来源:class.ebay.notifications.listener.php

示例10: 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

示例11: 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


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