コード例 #1
0
 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
0
ファイル: SessionOrder.php プロジェクト: saiber/www
 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
0
ファイル: UserAddress.php プロジェクト: saiber/livecart
 public function unserialize($serialized)
 {
     parent::unserialize($serialized);
     if ($this->serializedState) {
         $this->state->set(State::getInstanceByID($this->serializedState, true));
     }
 }
コード例 #4
0
ファイル: DeliveryZoneController.php プロジェクト: saiber/www
 /**
  * @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
0
ファイル: UserAddressApi.php プロジェクト: saiber/www
 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
0
ファイル: DeliveryZoneTest.php プロジェクト: saiber/livecart
 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
0
ファイル: UserAddress.php プロジェクト: saiber/www
 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
0
 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;
 }