本文整理汇总了PHP中Address::setPostalCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::setPostalCode方法的具体用法?PHP Address::setPostalCode怎么用?PHP Address::setPostalCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::setPostalCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLatLongValidation
function testLatLongValidation()
{
$address = new Address();
$address->setLine1("900 Winslow Way");
$address->setLine2("Ste 130");
$address->setCity("Bainbridge Island");
$address->setRegion("WA");
$address->setPostalCode("98110");
$address->setLongitude("-122.510359");
$address->setLatitude("47.624972");
$validateRequest = new ValidateRequest();
$validateRequest->setAddress($address);
$validateRequest->setTextCase(TextCase::$Upper);
//added for 4.13 changes
$validateRequest->setCoordinates(true);
//Sets Profile name from Configuration File to "Jaas"
//this will force it to Jaas (PostLocate)
$this->client = new AddressServiceSoap("JaasDevelopement");
//validate the Request
$result = $this->client->validate($validateRequest);
//Re-Assigning to the original Profile
$this->client = new AddressServiceSoap("Development");
$this->assertEqual($result->getResultCode(), SeverityLevel::$Success);
$validAddresses = $result->getValidAddresses();
$this->assertEqual(1, count($validAddresses));
$validAddresses = $result->getValidAddresses();
if (count($validAddresses) != 1) {
echo "Unexpected number of addresses returned. Expected one address.";
} else {
$validAddress = $validAddresses[0];
$this->assertEqual(strtoupper($address->getLine1()) . " E " . strtoupper($address->getLine2()), $validAddress->getLine1());
$this->assertEqual("", $validAddress->getLine2());
$this->assertEqual(strtoupper($address->getCity()), $validAddress->getCity());
$this->assertEqual(strtoupper($address->getRegion()), $validAddress->getRegion());
$this->assertEqual($address->getPostalCode() . "-2450", $validAddress->getPostalCode());
$this->assertEqual("H", $validAddress->getAddressType());
$this->assertEqual("C051", $validAddress->getCarrierRoute());
//Ticket 21203: Modified Fips Code value for jaas enabled account.
//$this->assertEqual("5303500000", $validAddress->getFipsCode());
$this->assertEqual("5303503736", $validAddress->getFipsCode());
$this->assertEqual("KITSAP", $validAddress->getCounty());
$this->assertEqual(strtoupper($address->getCity()) . " " . strtoupper($address->getRegion()) . " " . $address->getPostalCode() . "-2450", $validAddress->getLine4());
$this->assertEqual("981102450307", $validAddress->getPostNet());
// Added 4.13 changes for the Lat Long
// Update to check for ZIP+4 precision
// Zip+4 precision coordinates
if (strlen($validAddress->getLatitude()) > 7) {
echo "ZIP+4 precision coordinates received";
$this->assertEqual($address->getLatitude(), $validAddress->getLatitude());
$this->assertEqual($address->getLongitude(), $validAddress->getLongitude());
} else {
echo "ZIP5 precision coordinates received";
$this->assertEqual(substr($validAddress->getLatitude(), 0, 4), substr($address->getLatitude(), 0, 4), "Expected Latitude to start with '47.64'");
$this->assertEqual(substr($validAddress->getLongitude(), 0, 6), substr($address->getLongitude(), 0, 6), "Expected Longitude to start with '-122.53'");
}
}
}
示例2: _convertRequestAddress
/**
* Sets attributes from the Mage address on the AvaTax Request address.
*
* @return $this
*/
protected function _convertRequestAddress()
{
if (!$this->_requestAddress) {
$this->_requestAddress = new Address();
}
$this->_requestAddress->setLine1($this->_mageAddress->getStreet(1));
$this->_requestAddress->setLine2($this->_mageAddress->getStreet(2));
$this->_requestAddress->setCity($this->_mageAddress->getCity());
$this->_requestAddress->setRegion($this->_mageAddress->getRegionCode());
$this->_requestAddress->setCountry($this->_mageAddress->getCountry());
$this->_requestAddress->setPostalCode($this->_mageAddress->getPostcode());
return $this;
}
示例3: buildMerchants
public function buildMerchants($xml)
{
$merchants = new Merchants();
$merchants->setPageOffset((string) $xml->PageOffset);
$merchants->setTotalCount((string) $xml->TotalCount);
// merchant
$merchantArray = array();
foreach ($xml->Merchant as $merchant) {
$tmpMerchant = new Merchant();
$tmpMerchant->setId((string) $merchant->Id);
$tmpMerchant->setName((string) $merchant->Name);
$tmpMerchant->setWebsiteUrl((string) $merchant->WebsiteUrl);
$tmpMerchant->setPhoneNumber((string) $merchant->PhoneNumber);
$tmpMerchant->setCategory((string) $merchant->Category);
$tmpLocation = new Location();
$location = $merchant->Location;
$tmpLocation->setName((string) $location->Name);
$tmpLocation->setDistance((string) $location->Distance);
$tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
$tmpAddress = new Address();
$address = $location->Address;
$tmpAddress->setLine1((string) $address->Line1);
$tmpAddress->setLine2((string) $address->Line2);
$tmpAddress->setCity((string) $address->City);
$tmpAddress->setPostalCode((string) $address->PostCode);
$tmpCountry = new Country();
$tmpCountry->setName((string) $address->Country->Name);
$tmpCountry->setCode((string) $address->Country->Code);
$tmpCountrySubdivision = new CountrySubdivision();
$tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
$tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
$tmpAddress->setCountry($tmpCountry);
$tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
$tmpPoint = new Point();
$point = $location->Point;
$tmpPoint->setLatitude((string) $point->Latitude);
$tmpPoint->setLongitude((string) $point->Longitude);
// ACCEPTANCE FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES>
//$tmpAcceptance = new Acceptance();
//$acceptance = $merchant->Acceptance;
// FEATURES FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES>
//$tmpFeatures = new Features();
//$features = $merchant->Features;
$tmpLocation->setPoint($tmpPoint);
$tmpLocation->setAddress($tmpAddress);
$tmpMerchant->setLocation($tmpLocation);
array_push($merchantArray, $tmpMerchant);
}
$merchants->setMerchant($merchantArray);
return $merchants;
}
示例4: buildAtms
public function buildAtms($xml)
{
$atms = new Atms();
$atms->setPageOffset($xml->PageOffset);
$atms->setTotalCount($xml->TotalCount);
$atmArray = array();
foreach ($xml->Atm as $atm) {
$tmpAtm = new Atm();
$tmpAtm->setHandicapAccessible((string) $atm->HandicapAccessible);
$tmpAtm->setCamera((string) $atm->Camera);
$tmpAtm->setAvailability((string) $atm->Availability);
$tmpAtm->setAccessFees((string) $atm->AccessFees);
$tmpAtm->setOwner((string) $atm->Owner);
$tmpAtm->setSharedDeposit((string) $atm->SharedDeposit);
$tmpAtm->setSurchargeFreeAlliance((string) $atm->SurchargeFreeAlliance);
$tmpAtm->setSponsor((string) $atm->Sponsor);
$tmpAtm->setSupportEMV((string) $atm->SupportEMV);
$tmpAtm->setSurchargeFreeAllianceNetwork((string) $atm->SurchargeFreeAllianceNetwork);
$tmpLocation = new Location();
$location = $atm->Location;
$tmpLocation->setName((string) $location->Name);
$tmpLocation->setDistance((string) $location->Distance);
$tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
$tmpAddress = new Address();
$address = $location->Address;
$tmpAddress->setLine1((string) $address->Line1);
$tmpAddress->setLine2((string) $address->Line2);
$tmpAddress->setCity((string) $address->City);
$tmpAddress->setPostalCode((string) $address->PostCode);
$tmpCountry = new Country();
$tmpCountry->setName((string) $address->Country->Name);
$tmpCountry->setCode((string) $address->Country->Code);
$tmpCountrySubdivision = new CountrySubdivision();
$tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
$tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
$tmpAddress->setCountry($tmpCountry);
$tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
$tmpPoint = new Point();
$point = $location->Point;
$tmpPoint->setLatitude((string) $point->Latitude);
$tmpPoint->setLongitude((string) $point->Longitude);
$tmpLocation->setPoint($tmpPoint);
$tmpLocation->setAddress($tmpAddress);
$tmpAtm->setLocation($tmpLocation);
array_push($atmArray, $tmpAtm);
}
$atms->setAtm($atmArray);
return $atms;
}
示例5: buildAtms
public function buildAtms($xml)
{
$pageOffset = (string) $xml->PageOffset;
$totalCount = (string) $xml->TotalCount;
$restaurantArray = array();
foreach ($xml->Restaurant as $restaurant) {
$tmpRestaurant = new Restaurant();
$tmpRestaurant->setId((string) $restaurant->Id);
$tmpRestaurant->setName((string) $restaurant->Name);
$tmpRestaurant->setWebsiteUrl((string) $restaurant->WebsiteUrl);
$tmpRestaurant->setPhoneNumber((string) $restaurant->PhoneNumber);
$tmpRestaurant->setCategory((string) $restaurant->Category);
$tmpRestaurant->setLocalFavoriteInd((string) $restaurant->LocalFavoriteInd);
$tmpRestaurant->setHiddenGemInd((string) $restaurant->HiddenGemInd);
$tmpLocation = new Location();
$location = $restaurant->Location;
$tmpLocation->setName((string) $location->Name);
$tmpLocation->setDistance((string) $location->Distance);
$tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
$tmpAddress = new Address();
$address = $location->Address;
$tmpAddress->setLine1((string) $address->Line1);
$tmpAddress->setLine2((string) $address->Line2);
$tmpAddress->setCity((string) $address->City);
$tmpAddress->setPostalCode((string) $address->PostCode);
$tmpCountry = new Country();
$tmpCountry->setName((string) $address->Country->Name);
$tmpCountry->setCode((string) $address->Country->Code);
$tmpCountrySubdivision = new CountrySubdivision();
$tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
$tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
$tmpAddress->setCountry($tmpCountry);
$tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
$tmpPoint = new Point();
$point = $location->Point;
$tmpPoint->setLatitude((string) $point->Latitude);
$tmpPoint->setLongitude((string) $point->Longitude);
$tmpLocation->setPoint($tmpPoint);
$tmpLocation->setAddress($tmpAddress);
$tmpRestaurant->setLocation($tmpLocation);
array_push($restaurantArray, $tmpRestaurant);
}
$restaurants = new Restaurants($pageOffset, $totalCount, $restaurantArray);
return $restaurants;
}
示例6: create_ecp_PaymentMethod
function create_ecp_PaymentMethod()
{
$uniqueValue = get_unique_value();
$merchantAccountId = 'account-' . $uniqueValue;
$merchantPaymentMethodId = 'pm-' . $uniqueValue;
$email = get_unique_value() . '@nomail.com';
$successUrl = 'http://good.com/';
//need a trailing slash
$errorUrl = 'http://bad.com/';
//need a trailing slash
$name = 'John Vindicia';
$addr1 = '303 Twin Dolphin Drive';
$city = 'Redwood City';
$district = 'CA';
$postalCode = '94065';
$country = 'US';
$address = new Address();
$address->setName($name);
$address->setAddr1($addr1);
$address->setCity($city);
$address->setDistrict($district);
$address->setPostalCode($postalCode);
$address->setCountry($country);
$paymentmethod = new PaymentMethod();
$paymentmethod->setType('ECP');
$paymentmethod->setAccountHolderName($name);
$paymentmethod->setBillingAddress($address);
$paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
$paymentmethod->setCurrency('USD');
$ecp = new ECP();
$ecp->setAccount('495958930');
$ecp->setRoutingNumber('611111111');
$ecp->setAllowedTransactionType('Inbound');
$ecp->setAccountType('ConsumerChecking');
$paymentmethod->setECP($ecp);
$account = new Account();
$account->setMerchantAccountId($merchantAccountId);
$account->setEmailAddress($email);
$account->setShippingAddress($address);
$account->setEmailTypePreference('html');
$account->setName($name);
$account->setPaymentMethods(array($paymentmethod));
return $account;
}
示例7: buildMerchantIds
public function buildMerchantIds($xml)
{
$merchantArray = array();
foreach ($xml->ReturnedMerchants->Merchant as $merchant) {
$xmlAddress = $merchant->Address;
$xmlCountrySubdivision = $merchant->Address->CountrySubdivision;
$xmlCountry = $merchant->Address->Country;
$xmlMerchant = $merchant;
$address = new Address();
$address->setLine1((string) $xmlAddress->Line1);
$address->setLine2((string) $xmlAddress->Line2);
$address->setCity((string) $xmlAddress->City);
$address->setPostalCode((string) $xmlAddress->PostalCode);
$countrySubdivision = new CountrySubdivision();
$countrySubdivision->setCode((string) $xmlCountrySubdivision->Code);
$countrySubdivision->setName((string) $xmlCountrySubdivision->Name);
$country = new Country();
$country->setCode((string) $xmlCountry->Code);
$country->setName((string) $xmlCountry->Name);
$address->setCountrySubdivision($countrySubdivision);
$address->setCountry($country);
$tmpMerchant = new Merchant();
$tmpMerchant->setAddress($address);
$tmpMerchant->setPhoneNumber((string) $xmlMerchant->PhoneNumber);
$tmpMerchant->setBrandName((string) $xmlMerchant->BrandName);
$tmpMerchant->setMerchantCategory((string) $xmlMerchant->MerchantCategory);
$tmpMerchant->setMerchantDbaName((string) $xmlMerchant->MerchantDbaName);
$tmpMerchant->setDescriptorText((string) $xmlMerchant->DescriptorText);
$tmpMerchant->setLegalCorporateName((string) $xmlMerchant->LegalCorporateName);
$tmpMerchant->setBrickCount((string) $xmlMerchant->BrickCount);
$tmpMerchant->setComment((string) $xmlMerchant->Comment);
$tmpMerchant->setLocationId((string) $xmlMerchant->LocationId);
$tmpMerchant->setOnlineCount((string) $xmlMerchant->OnlineCount);
$tmpMerchant->setOtherCount((string) $xmlMerchant->OtherCount);
$tmpMerchant->setSoleProprietorName((string) $xmlMerchant->SoleProprietorName);
array_push($merchantArray, $tmpMerchant);
}
$returnedMerchants = new ReturnedMerchants();
$returnedMerchants->setMerchant($merchantArray);
$merchantIds = new MerchantIds();
$merchantIds->setReturnedMerchants($returnedMerchants);
$merchantIds->setMessage($xml->Message);
return $merchantIds;
}
示例8: create_paypal_PaymentMethod
function create_paypal_PaymentMethod()
{
$uniqueValue = get_unique_value();
$merchantAccountId = 'account-' . $uniqueValue;
$merchantPaymentMethodId = 'pm-' . $uniqueValue;
$email = get_unique_value() . '@nomail.com';
$successUrl = 'http://good.com/';
//need a trailing slash
$errorUrl = 'http://bad.com/';
//need a trailing slash
$name = 'John Vindicia';
$addr1 = '303 Twin Dolphin Drive';
$city = 'Redwood City';
$district = 'CA';
$postalCode = '94065';
$country = 'US';
$address = new Address();
$address->setName($name);
$address->setAddr1($addr1);
$address->setCity($city);
$address->setDistrict($district);
$address->setPostalCode($postalCode);
$address->setCountry($country);
$paymentmethod = new PaymentMethod();
$paymentmethod->setType('PayPal');
$paymentmethod->setAccountHolderName($name);
$paymentmethod->setBillingAddress($address);
$paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
$paymentmethod->setCurrency('USD');
$paypal = new PayPal();
$paypal->setReturnUrl($successUrl);
$paypal->setCancelUrl($errorUrl);
$paymentmethod->setPaypal($paypal);
$account = new Account();
$account->setMerchantAccountId($merchantAccountId);
$account->setEmailAddress($email);
$account->setShippingAddress($address);
$account->setEmailTypePreference('html');
$account->setName($name);
//$account->setPaymentMethods(array($paymentmethod));
//return $account;
return array('account' => $account, 'paymentmethod' => $paymentmethod);
}
示例9: setShippingAddress
/**
* @param Address $address
* @return boolean
*/
public function setShippingAddress($shippingAddress)
{
$bool = $this->shippingAddress->setStreetAddress($shippingAddress->getStreetAddress());
if (!$bool) {
return FALSE;
}
$bool = $this->shippingAddress->setCity($shippingAddress->getCity());
if (!$bool) {
return FALSE;
}
$bool = $this->shippingAddress->setParish($shippingAddress->getParish());
if (!$bool) {
return FALSE;
}
$bool = $this->shippingAddress->setPostalCode($shippingAddress->getPostalCode());
if (!$bool) {
return FALSE;
}
return TRUE;
}
示例10: GetTaxRequest
function wc_autoship_taxnow_add_tax_rates($tax_rates, $schedule_id)
{
include_once WP_PLUGIN_DIR . '/taxnow_woo/taxnow-woo.class.php';
include_once WP_PLUGIN_DIR . '/woocommerce-autoship/classes/wc-autoship-schedule.php';
if (class_exists('class_taxNOW_woo') && class_exists('WC_Autoship_Schedule')) {
// Create TaxNOW instance
$taxnow_woo = new class_taxNOW_woo();
// Get autoship schedule
$schedule = new WC_Autoship_Schedule($schedule_id);
// Get autoship customer
$customer = $schedule->get_customer();
// Create service
$service = $taxnow_woo->create_service('TaxServiceSoap', false);
$request = new GetTaxRequest();
$request->setDocDate(date('Y-m-d', current_time('timestamp')));
$request->setDocCode('');
$request->setCustomerCode($customer->get_email());
$request->setCompanyCode(get_option('tnwoo_company_code'));
$request->setDocType(DocumentType::$SalesOrder);
$request->setDetailLevel(DetailLevel::$Tax);
$request->setCurrencyCode(get_option('woocommerce_currency'));
$request->setBusinessIdentificationNo(get_option('tnwoo_business_vat_id'));
// Origin address
$origin = new Address();
$origin->setLine1(get_option('tnwoo_origin_street'));
$origin->setCity(get_option('tnwoo_origin_city'));
$origin->setRegion(get_option('tnwoo_origin_state'));
$origin->setPostalCode(get_option('tnwoo_origin_zip'));
$origin->setCountry(get_option('tnwoo_origin_country'));
$request->setOriginAddress($origin);
// Destination address
$destination = new Address();
$destination->setLine1($customer->get('shipping_address_1'));
$destination->setCity($customer->get('shipping_city'));
$destination->setRegion($customer->get('shipping_state'));
$destination->setPostalCode($customer->get('shipping_postcode'));
$destination->setCountry($customer->get('shipping_country'));
$request->setDestinationAddress($destination);
// Lines items
$items = $schedule->get_items();
$lines = array();
$global_tax_code = get_option('tnwoo_default_tax_code');
foreach ($items as $i => $item) {
// Get WooCommerce product ID
$product_id = $item->get_product_id();
// Create line item
$line = new Line();
$line->setItemCode($product_id);
$line->setDescription($product_id);
$tax_code = get_post_meta($product_id, '_taxnow_taxcode', true);
$line->setTaxCode(!empty($tax_code) ? $tax_code : $global_tax_code);
$line->setQty((int) $item->get_quantity());
$line->setAmount((double) $item->get_autoship_price());
$line->setNo($i + 1);
$line->setDiscounted(0);
$lines[] = $line;
}
$request->setLines($lines);
// Pretax discount
$discount_pretax = 0.0;
// Send request
$taxnow_woo->log_add_entry('calculate_tax', 'request', $request);
try {
$response = $service->getTax($request);
$taxnow_woo->log_add_entry('calculate_tax', 'response', $response);
if ($response->getResultCode() == SeverityLevel::$Success) {
foreach ($response->GetTaxLines() as $l => $TaxLine) {
foreach ($TaxLine->getTaxDetails() as $d => $TaxDetail) {
// Create WooCommerce tax rate
$tax_rate = array('rate' => 100.0 * $TaxDetail->getRate(), 'label' => $TaxDetail->getTaxName(), 'shipping' => 'no', 'compound' => 'no');
$tax_rates["wc_autoship_taxnow_{$l}_{$d}"] = $tax_rate;
}
}
}
} catch (Exception $e) {
$taxnow_woo->log_add_entry('calculate_tax', 'exception', $e->getMessage());
}
}
// Return tax rates
return $tax_rates;
}
示例11: rand
require_once 'Vindicia/Soap/Const.php';
$parentID = $argv[1];
print "parent: {$parentID} \n";
$name = "Child One";
$addr1 = "19 Davis Dr";
$city = "Belmont";
$state = "CA";
$postalcode = "94002";
$country = "US";
$email = "childAccount" . rand(10000, 99999) . "@vindicia.com";
$address = new Address();
$address->setName($name);
$address->setAddr1($addr1);
$address->setCity($city);
$address->setDistrict($state);
$address->setPostalCode($postalcode);
$address->setCountry($country);
$accountID = "childAccount" . rand(1000, 9999) . "-" . rand(1000, 999999);
$child1 = new Account();
$child1->setMerchantAccountId($accountID);
$child1->setEmailAddress($email);
$child1->setShippingAddress($address);
$child1->setEmailTypePreference('html');
$child1->setWarnBeforeAutoBilling(false);
$child1->setName($name);
$parent = new Account();
$parent->setMerchantAccountId($parentID);
// use the force flag to remove these children from a previous parent
// and assign them to this new one
//$force=true;
$force = false;
示例12: getUserAddEditForm
//.........这里部分代码省略.........
//31 is the ID of Canada. It should be a SiteConfig variable
$form->addElement('hidden', 'shipping_country');
$form->addElement('static', 'shipping_country1', 'Country', 'Canada');
$form->addElement('header', 'save', 'Save');
if ($admin) {
$form->addElement('select', 'a_status', 'Active Status', $statuses);
}
$form->addElement('submit', 'a_submit', 'Save');
$form->addElement('reset', 'a_cancel', 'Cancel');
if (isset($this->user) && $this->user->hasPerm('assigngroups')) {
$sql = 'SELECT agp_id, agp_name from auth_groups';
$groups = Database::singleton()->query_fetch_all($sql);
$assignableGroup = array();
foreach ($groups as $group) {
$assignableGroup[$group['agp_id']] = $group['agp_name'];
}
if (@$this) {
$defaultValues['a_group'] = $this->getAuthGroup();
}
$form->addElement('select', 'a_group', 'Member Group', $assignableGroup);
}
$defaultValues['a_username'] = $this->getUsername();
$defaultValues['a_name'] = $this->getName();
//$defaultValues ['a_email'] = $this->getEmail();
$defaultValues['a_phone'] = $this->getPhone();
$defaultValues['a_join_newsletter'] = $this->getJoinNewsletter();
$defaultValues['a_password'] = null;
$defaultValues['a_password_confirm'] = null;
if (@$this->getAddress()) {
$defaultValues['a_address'] = @$this->getAddress()->getStreetAddress();
$defaultValues['a_city'] = @$this->getAddress()->getCity();
$defaultValues['a_postalcode'] = @$this->getAddress()->getPostalCode();
}
if (@$this->getShippingAddress()) {
$defaultValues['shipping_address'] = @$this->getShippingAddress()->getStreetAddress();
$defaultValues['shipping_city'] = @$this->getShippingAddress()->getCity();
$defaultValues['shipping_postalcode'] = @$this->getShippingAddress()->getPostalCode();
}
if ($admin) {
$defaultValues['a_status'] = $this->getActiveStatus();
}
$form->setDefaults($defaultValues);
$form->addRule('a_name', 'Please enter the user\'s name', 'required', null, 'client');
//$form->addRule( 'a_email', 'Please enter an email address', 'required', null, 'client' );
//$form->addRule( 'a_email', 'Please enter a valid email address', 'email', null, 'client' );
$form->addRule('a_phone', 'Please enter a phone number', 'required', null, 'client');
$form->addRule('a_address', 'Please enter a billing address', 'required', null, 'client');
$form->addRule('a_city', 'Please enter a billing address city', 'required', null, 'client');
$form->addRule('a_postalcode', 'Please enter a billing address postal code', 'required', null, 'client');
$form->addRule('shipping_address', 'Please enter a shipping address', 'required', null, 'client');
$form->addRule('shipping_city', 'Please enter a shipping address city', 'required', null, 'client');
$form->addRule('shipping_postalcode', 'Please enter a shipping address postal code', 'required', null, 'client');
if (!isset($_REQUEST['id'])) {
$form->addRule('a_password', 'Please enter a password', 'required', null, 'client');
$form->addRule('a_password_confirm', 'Please confirm the passwords match', 'required', null, 'client');
}
$form->addRule(array('a_password', 'a_password_confirm'), 'The passwords do not match', 'compare', null, 'client');
if (isset($_REQUEST['a_submit']) && $form->validate()) {
$this->setPassword($_REQUEST['a_password']);
if ($admin || @(!$_REQUEST['id'])) {
$this->setUsername($_REQUEST['a_username']);
$this->setEmail($_REQUEST['a_username']);
}
$this->setActiveStatus(1);
$this->setPhone($_REQUEST['a_phone']);
$this->setName($_REQUEST['a_name']);
$this->setJoinNewsletter(@$_REQUEST['a_join_newsletter']);
if (@$this->getAddress()) {
$billingTemp = new Address(@$this->getAddress()->getId());
} else {
$billingTemp = new Address();
}
$billingTemp->setStreetAddress($_REQUEST['a_address']);
$billingTemp->setCity($_REQUEST['a_city']);
$billingTemp->setPostalCode($_REQUEST['a_postalcode']);
$billingTemp->setState($_REQUEST['a_state']);
$billingTemp->setCountry($_REQUEST['a_country']);
$billingTemp->save();
$this->setAddress($billingTemp);
if (@$this->getShippingAddress()) {
$shippingTemp = new Address(@$this->getShippingAddress()->getId());
} else {
$shippingTemp = new Address();
}
$shippingTemp->setStreetAddress($_REQUEST['shipping_address']);
$shippingTemp->setCity($_REQUEST['shipping_city']);
$shippingTemp->setPostalCode($_REQUEST['shipping_postalcode']);
$shippingTemp->setState($_REQUEST['shipping_state']);
$shippingTemp->setCountry($_REQUEST['shipping_country']);
$shippingTemp->save();
$this->setShippingAddress($shippingTemp);
if ($this->save()) {
$_REQUEST["user_created"] = 1;
} else {
$form->addElement('static', 'Message', 'Username already exists');
$_REQUEST["username_already_exists"] = 1;
}
}
return $form;
}
示例13: createStandardRequest
function createStandardRequest($calc, $products, $sign = 1)
{
if (!class_exists('TaxServiceSoap')) {
require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php';
}
if (!class_exists('DocumentType')) {
require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php';
}
if (!class_exists('DetailLevel')) {
require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php';
}
if (!class_exists('Line')) {
require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
}
if (!class_exists('ServiceMode')) {
require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php';
}
if (!class_exists('Line')) {
require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
}
if (!class_exists('GetTaxRequest')) {
require VMAVALARA_CLASS_PATH . DS . 'GetTaxRequest.class.php';
}
if (!class_exists('GetTaxResult')) {
require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php';
}
if (!class_exists('Address')) {
require VMAVALARA_CLASS_PATH . DS . 'Address.class.php';
}
if (is_object($calc)) {
$calc = get_object_vars($calc);
}
$request = new GetTaxRequest();
$origin = new Address();
//In Virtuemart we have not differenct warehouses, but we have a shipment address
//So when the vendor has a shipment address, we assume that it is his warehouse
//Later we can combine products with shipment addresses for different warehouse (yehye, future music)
//But for now we just use the BT address
if (!class_exists('VirtueMartModelVendor')) {
require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
}
$userId = VirtueMartModelVendor::getUserIdByVendorId($calc['virtuemart_vendor_id']);
$userModel = VmModel::getModel('user');
$virtuemart_userinfo_id = $userModel->getBTuserinfo_id($userId);
// this is needed to set the correct user id for the vendor when the user is logged
$userModel->getVendor($calc['virtuemart_vendor_id']);
$vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $virtuemart_userinfo_id, FALSE, TRUE);
$vendorFields = $vendorFieldsArray[$virtuemart_userinfo_id];
$origin->setLine1($vendorFields['fields']['address_1']['value']);
$origin->setLine2($vendorFields['fields']['address_2']['value']);
$origin->setCity($vendorFields['fields']['city']['value']);
$origin->setCountry($vendorFields['fields']['virtuemart_country_id']['country_2_code']);
$origin->setRegion($vendorFields['fields']['virtuemart_state_id']['state_2_code']);
$origin->setPostalCode($vendorFields['fields']['zip']['value']);
$request->setOriginAddress($origin);
//Address
if (isset($this->addresses[0])) {
$destination = $this->addresses[0];
} else {
return FALSE;
}
if (!class_exists('calculationHelper')) {
require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
}
$calculator = calculationHelper::getInstance();
$request->setCurrencyCode($calculator->_currencyDisplay->_vendorCurrency_code_3);
//CurrencyCode
$request->setDestinationAddress($destination);
//Address
$request->setCompanyCode($calc['company_code']);
// Your Company Code From the Dashboard
$request->setDocDate(date('Y-m-d'));
//date, checked
$request->setCustomerCode(self::$vmadd['customer_number']);
//string Required
if (isset(self::$vmadd['tax_usage_type'])) {
$request->setCustomerUsageType(self::$vmadd['tax_usage_type']);
//string Entity Usage
}
if (isset(self::$vmadd['tax_exemption_number'])) {
$request->setExemptionNo(self::$vmadd['tax_exemption_number']);
//string if not using ECMS which keys on customer code
}
if (isset(self::$vmadd['taxOverride'])) {
$request->setTaxOverride(self::$vmadd['taxOverride']);
avadebug('I set tax override ', self::$vmadd['taxOverride']);
}
$setAllDiscounted = false;
if (isset($products['discountAmount'])) {
if (!empty($products['discountAmount'])) {
//$request->setDiscount($sign * $products['discountAmount'] * (-1)); //decimal
$request->setDiscount($sign * $products['discountAmount']);
//decimal
vmdebug('We sent as discount ' . $request->getDiscount());
$setAllDiscounted = true;
}
unset($products['discountAmount']);
}
$request->setDetailLevel('Tax');
//Summary or Document or Line or Tax or Diagnostic
//.........这里部分代码省略.........
示例14: rtrim
$address->setLine1($input);
echo "Address Line 2: ";
$input = rtrim(fgets($STDIN));
$address->setLine2($input);
echo "Address Line 3: ";
$input = rtrim(fgets($STDIN));
$address->setLine3($input);
echo "City: ";
$input = rtrim(fgets($STDIN));
$address->setCity($input);
echo "State/Province: ";
$input = rtrim(fgets($STDIN));
$address->setRegion($input);
echo "Postal Code: ";
$input = rtrim(fgets($STDIN));
$address->setPostalCode($input);
$textCase = TextCase::$Mixed;
$coordinates = 1;
$request = new ValidateRequest($address, $textCase ? $textCase : TextCase::$Default, $coordinates);
$result = $client->Validate($request);
echo "\n" . 'Validate ResultCode is: ' . $result->getResultCode() . "\n";
if ($result->getResultCode() != SeverityLevel::$Success) {
foreach ($result->getMessages() as $msg) {
echo $msg->getName() . ": " . $msg->getSummary() . "\n";
}
} else {
echo "Normalized Address:\n";
foreach ($result->getvalidAddresses() as $valid) {
echo "Line 1: " . $valid->getline1() . "\n";
echo "Line 2: " . $valid->getline2() . "\n";
echo "Line 3: " . $valid->getline3() . "\n";
示例15: convertAddress
/**
* Converts the address fetched from the database to the Address object.
*/
private function convertAddress($row)
{
$formatted = $row['unstructured_address'];
if (empty($formatted)) {
$formatted = trim($row['street_address'] . " " . $row['region'] . " " . $row['country']);
$formatted = empty($formatted) ? $formatted : null;
}
$address = new Address($formatted);
$address->setCountry($row['country']);
$address->setLatitude($row['latitude']);
$address->setLongitude($row['longitude']);
$address->setLocality($row['locality']);
$address->setPostalCode($row['postal_code']);
$address->setRegion($row['region']);
$address->setStreetAddress($row['street_address']);
$address->setType($row['address_type']);
$address->setUnstructuredAddress($row['unstructured_address']);
$address->setExtendedAddress($row['extended_address']);
$address->setPoBox($row['po_box']);
return $address;
}