本文整理汇总了PHP中State::getInstanceByID方法的典型用法代码示例。如果您正苦于以下问题:PHP State::getInstanceByID方法的具体用法?PHP State::getInstanceByID怎么用?PHP State::getInstanceByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类State
的用法示例。
在下文中一共展示了State::getInstanceByID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$this->zone = DeliveryZone::getNewInstance();
$this->zone->name->set(':TEST_ZONE');
$this->zone->isEnabled->set(1);
$this->zone->isFreeShipping->set(1);
$this->zone->save();
$this->alaska = State::getInstanceByID(1, true, true);
}
示例2: getDefaultEstimateAddress
public static function getDefaultEstimateAddress()
{
$config = ActiveRecordModel::getApplication()->getConfig();
$address = UserAddress::getNewInstance();
$address->countryID->set($config->get('DEF_COUNTRY'));
if ($state = $config->get('DEF_STATE')) {
$address->state->set(State::getInstanceByID($config->get('DEF_STATE')));
}
return $address;
}
示例3: unserialize
public function unserialize($serialized)
{
parent::unserialize($serialized);
if ($this->serializedState) {
$this->state->set(State::getInstanceByID($this->serializedState, true));
}
}
示例4: saveStates
/**
* @role update
*/
public function saveStates()
{
$zone = DeliveryZone::getInstanceByID((int) $this->getId());
DeliveryZoneState::removeByZone($zone);
foreach ((array) $this->request->get('active') as $activeStateID) {
$state = State::getInstanceByID((int) $activeStateID);
$deliveryZoneState = DeliveryZoneState::getNewInstance($zone, $state);
$deliveryZoneState->save();
}
return new JSONResponse(false, 'success');
}
示例5: update
public function update()
{
$request = $this->application->getRequest();
$parser = $this->getParser();
$response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
$id = $request->get('ID');
$f = new ARSelectFilter();
if (intval($id) > 0) {
$f->mergeCondition(new EqualsCond(new ARFieldHandle('UserAddress', 'ID'), $id));
} else {
throw new Exception('Address ID is required');
}
$user_address = UserAddress::getInstanceById($id);
$firstName = $request->get('firstName');
$lastName = $request->get('lastName');
$companyName = $request->get('companyName');
$address1 = $request->get('address1');
$address2 = $request->get('address2');
$city = $request->get('city');
$stateName = $request->get('stateName');
$stateID = $request->get('stateID');
$postalCode = $request->get('postalCode');
$countryID = $request->get('countryID');
$phone = $request->get('phone');
if (isset($firstName)) {
$user_address->setFieldValue('firstName', $firstName);
}
if (isset($lastName)) {
$user_address->setFieldValue('lastName', $lastName);
}
if (isset($companyName)) {
$user_address->setFieldValue('companyName', $companyName);
}
if (isset($address1)) {
$user_address->setFieldValue('address1', $address1);
}
if (isset($address2)) {
$user_address->setFieldValue('address2', $address2);
}
if (isset($city)) {
$user_address->setFieldValue('city', $city);
}
if (isset($stateName)) {
$user_address->setFieldValue('stateName', $stateName);
}
if (isset($stateID)) {
$user_address->state->set(State::getInstanceByID((int) $stateID, true));
}
if (isset($postalCode)) {
$user_address->setFieldValue('postalCode', $postalCode);
}
if (isset($countryID)) {
$user_address->setFieldValue('countryID', $countryID);
}
if (isset($phone)) {
$user_address->setFieldValue('phone', $phone);
}
$user_address->save();
$apiFieldNames = $parser->getApiFieldNames();
$user_record = ActiveRecordModel::getRecordSetArray('UserAddress', $f);
while ($address = array_shift($user_record)) {
$user_address_response = $response->addChild('user_address');
foreach ($address as $k => $v) {
if (in_array($k, $apiFieldNames)) {
$user_address_response->addChild($k, htmlentities($v));
}
}
}
return new SimpleXMLResponse($response);
}
示例6: testGetDeliveryZoneStates
public function testGetDeliveryZoneStates()
{
$zone = DeliveryZone::getNewInstance();
$zone->name->set(':TEST_ZONE');
$zone->save();
$deliveryState = DeliveryZoneState::getNewInstance($zone, State::getInstanceByID(1));
$deliveryState->save();
$states = $zone->getStates();
$this->assertEquals($states->getTotalRecordCount(), 1);
$this->assertTrue($states->get(0) === $deliveryState);
}
示例7: loadRequestData
public function loadRequestData(Request $request, $prefix = '')
{
parent::loadRequestData($request, $prefix);
if ($request->get($prefix . 'stateID')) {
$this->state->set(State::getInstanceByID((int) $request->get($prefix . 'stateID'), true));
$this->stateName->set(null);
} else {
if ($request->isValueSet($prefix . 'stateName')) {
$this->stateName->set($request->get($prefix . 'stateName'));
$this->state->set(null);
}
}
}
示例8: getAddresses
private function getAddresses($array)
{
$addresses = array();
foreach ($array['CALCULATE'][0]['ADDRESSES'][0]['ANONYMOUS-ADDRESS'] as $address) {
$ua = UserAddress::getNewInstance();
foreach (array('COUNTRY-CODE' => 'countryID', 'POSTAL-CODE' => 'postalCode', 'CITY' => 'city', 'REGION' => 'stateName') as $google => $livecart) {
$ua->{$livecart}->set($address[$google][0]['VALUE']);
}
// state lookup
if ($stateID = State::getStateIDByName($ua->countryID->get(), $ua->stateName->get())) {
$ua->state->set(State::getInstanceByID($stateID, true));
}
$ua->countryID->set($address['COUNTRY-CODE'][0]['VALUE']);
$addresses[$address['ATTRIBUTES']['ID']] = $ua;
}
return $addresses;
}