本文整理汇总了PHP中Region::shipping_regions方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::shipping_regions方法的具体用法?PHP Region::shipping_regions怎么用?PHP Region::shipping_regions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Region
的用法示例。
在下文中一共展示了Region::shipping_regions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FieldHolder
function FieldHolder()
{
$regions = Region::shipping_regions();
$jsonRegions = json_encode($regions);
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascriptTemplate('swipestripe/javascript/RegionField.js', array("regions" => $jsonRegions, 'defaultValue' => $this->Value()));
return parent::FieldHolder();
}
示例2: addShippingAddressFields
/**
* Add fields for shipping address and required fields to the validator.
*
* @param Array $fields Array of fields
* @param OrderFormValidator $validator Checkout form validator
*/
private function addShippingAddressFields(&$fields, &$validator)
{
$firstNameField = new TextField('Shipping[FirstName]', _t('CheckoutPage.FIRSTNAME', "First Name"));
$firstNameField->addExtraClass('shipping-firstname');
$firstNameField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_FIRSTNAME', "Please enter a first name."));
$surnameField = new TextField('Shipping[Surname]', _t('CheckoutPage.SURNAME', "Surname"));
$surnameField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_SURNAME', "Please enter a surname."));
$addressField = new TextField('Shipping[Address]', _t('CheckoutPage.ADDRESS1', "Address 1"));
$addressField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_ADDRESS', "Please enter an address."));
$cityField = new TextField('Shipping[City]', _t('CheckoutPage.CITY', "City"));
$cityField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_CITY', "Please enter a city."));
$countryField = new DropdownField('Shipping[Country]', _t('CheckoutPage.COUNTRY', "Country"), Country::shipping_countries());
$countryField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_COUNTRY', "Please enter a country."));
if (!Member::currentUserID() && Geoip::$default_country_code) {
$countryField->setValue(Geoip::$default_country_code);
}
$regions = Region::shipping_regions();
$regionField = null;
if (!empty($regions)) {
$regionField = new RegionField('Shipping[Region]', _t('CheckoutPage.REGION', "Region"));
$regionField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_REGION', "Please enter a country."));
}
$sameAddressField = new CheckboxField('ShipToBillingAddress', _t('CheckoutPage.SAME_ADDRESS', "to same address?"));
$sameAddressField->addExtraClass('shipping-same-address');
$shippingAddressFields = new CompositeField(new HeaderField(_t('CheckoutPage.SHIPPING_ADDRESS', "Shipping Address"), 3), $sameAddressField, $firstNameField, $surnameField, new TextField('Shipping[Company]', _t('CheckoutPage.COMPANY', "Company")), $addressField, new TextField('Shipping[AddressLine2]', _t('CheckoutPage.ADDRESS2', "Address 2")), $cityField, new TextField('Shipping[PostalCode]', _t('CheckoutPage.POSTAL_CODE', "Postal Code")), new TextField('Shipping[State]', _t('CheckoutPage.STATE', "State")), $countryField);
if ($regionField) {
$shippingAddressFields->push($regionField);
}
$shippingAddressFields->setID('ShippingAddress');
$fields['ShippingAddress'][] = $shippingAddressFields;
$validator->addRequiredField('Shipping[FirstName]');
$validator->addRequiredField('Shipping[Surname]');
$validator->addRequiredField('Shipping[Address]');
$validator->addRequiredField('Shipping[City]');
$validator->addRequiredField('Shipping[Country]');
}
示例3: addAddressesAtCheckout
/**
* Add addresses to this Order at the checkout.
*
* @param Array $data
*/
function addAddressesAtCheckout(array $data)
{
$member = Customer::currentUser() ? Customer::currentUser() : singleton('Customer');
$order = CartControllerExtension::get_current_order();
$billingCountries = Country::billing_countries();
$shippingCountries = Country::shipping_countries();
$shippingRegions = Region::shipping_regions();
//If there is a current billing and shipping address, update them, otherwise create new ones
$existingBillingAddress = $this->BillingAddress();
$existingShippingAddress = $this->ShippingAddress();
if ($existingBillingAddress && $existingBillingAddress->exists()) {
$newData = array();
if (isset($data['Billing']) && is_array($data['Billing'])) {
foreach ($data['Billing'] as $fieldName => $value) {
$newData[$fieldName] = $value;
}
}
$newData['CountryID'] = $data['Billing']['Country'];
$newData['CountryName'] = in_array($newData['CountryID'], array_keys($billingCountries)) ? $billingCountries[$newData['CountryID']] : null;
if ($member->ID) {
$newData['MemberID'] = $member->ID;
}
$existingBillingAddress->update($newData);
$existingBillingAddress->write();
} else {
$billingAddress = new Address();
$billingAddress->OrderID = $order->ID;
if ($member->ID) {
$billingAddress->MemberID = $member->ID;
}
$billingAddress->FirstName = $data['Billing']['FirstName'];
$billingAddress->Surname = $data['Billing']['Surname'];
$billingAddress->Company = $data['Billing']['Company'];
$billingAddress->Address = $data['Billing']['Address'];
$billingAddress->AddressLine2 = $data['Billing']['AddressLine2'];
$billingAddress->City = $data['Billing']['City'];
$billingAddress->PostalCode = $data['Billing']['PostalCode'];
$billingAddress->State = $data['Billing']['State'];
$billingAddress->CountryID = $data['Billing']['Country'];
$billingAddress->CountryName = in_array($data['Billing']['Country'], array_keys($billingCountries)) ? $billingCountries[$data['Billing']['Country']] : null;
$billingAddress->Type = 'Billing';
$billingAddress->write();
}
if ($existingShippingAddress && $existingShippingAddress->exists()) {
$newData = array();
if (isset($data['Shipping']) && is_array($data['Shipping'])) {
foreach ($data['Shipping'] as $fieldName => $value) {
$newData[$fieldName] = $value;
}
}
$newData['CountryID'] = $data['Shipping']['Country'];
$newData['CountryName'] = in_array($newData['CountryID'], array_keys($shippingCountries)) ? $shippingCountries[$newData['CountryID']] : null;
if (isset($newData['Region']) && isset($shippingRegions[$newData['Country']])) {
if (in_array($newData['Region'], array_keys($shippingRegions[$newData['Country']]))) {
$newData['RegionName'] = $shippingRegions[$newData['Country']][$newData['Region']];
}
} else {
$newData['RegionName'] = null;
}
if ($member->ID) {
$newData['MemberID'] = $member->ID;
}
$existingShippingAddress->update($newData);
$existingShippingAddress->write();
} else {
$shippingAddress = new Address();
$shippingAddress->OrderID = $order->ID;
if ($member->ID) {
$shippingAddress->MemberID = $member->ID;
}
$shippingAddress->FirstName = $data['Shipping']['FirstName'];
$shippingAddress->Surname = $data['Shipping']['Surname'];
$shippingAddress->Company = $data['Shipping']['Company'];
$shippingAddress->Address = $data['Shipping']['Address'];
$shippingAddress->AddressLine2 = $data['Shipping']['AddressLine2'];
$shippingAddress->City = $data['Shipping']['City'];
$shippingAddress->PostalCode = $data['Shipping']['PostalCode'];
$shippingAddress->State = $data['Shipping']['State'];
$shippingAddress->CountryID = $data['Shipping']['Country'];
$shippingAddress->Region = isset($data['Shipping']['Region']) ? $data['Shipping']['Region'] : null;
$shippingAddress->CountryName = in_array($data['Shipping']['Country'], array_keys($shippingCountries)) ? $shippingCountries[$data['Shipping']['Country']] : null;
$shippingAddress->RegionName = isset($data['Shipping']['Region']) && isset($shippingRegions[$data['Shipping']['Country']]) && in_array($data['Shipping']['Region'], array_keys($shippingRegions[$data['Shipping']['Country']])) ? $shippingRegions[$data['Shipping']['Country']][$data['Shipping']['Region']] : null;
$shippingAddress->Type = 'Shipping';
$shippingAddress->write();
}
}