コード例 #1
0
 /**
  * Embed a single address form.
  *
  * @param  string $name
  * @param  string $type
  * @param  array  $options
  * @return void
  */
 protected function setEmbeddedAddressForm($name, $type, $options = array())
 {
     $options['object'] = isset($options['object']) ? $options['object'] : $this->object;
     $options['is_optional'] = isset($options['is_optional']) ? $options['is_optional'] : sfConfig::get('app_rt_account_address_is_optional_for_' . $type, true);
     $address = new rtAddress();
     $address->setType($type);
     $address->setModel('rtGuardUser');
     if (!$this->isNew()) {
         $tmp_address = Doctrine::getTable('rtAddress')->getAddressForObjectAndType($this->getObject(), $type);
         if ($tmp_address) {
             $address = $tmp_address;
         }
         $address->setModelId($this->object->getId());
     }
     $this->embedForm($name, $this->getAddressForm($address, $options));
 }
コード例 #2
0
 /**
  * Add address for order
  *
  * @param integer $order_id
  * @param string $type
  * @return integer
  */
 public function addAddressForOrder($order_id, $type = 'billing')
 {
     $address = new rtAddress();
     $address->setModelId($order_id);
     $address->setModel('rtShopOrder');
     $address->setFirstName('John');
     $address->setLastName('Doe');
     $address->setAddress_1('35 Doe Street');
     $address->setTown('Doetown');
     $address->setState('NSW');
     $address->setCountry('AU');
     $address->setPostcode(2010);
     $address->setPhone('0212345678');
     $address->setType($type);
     $address->save();
     return $address->getId();
 }
コード例 #3
0
 /**
  * Add address for order
  *
  * @param integer $order_id
  * @param string $type
  * @return integer
  */
 public function addAddressForOrder($order_id, $type = 'billing')
 {
     $address = new rtAddress();
     $address->setModelId($order_id);
     $address->setModel('rtShopOrder');
     $address->setFirstName('Konny');
     $address->setLastName('Zurcher');
     $address->setAddress_1('70 Mary Street');
     $address->setTown('Surry Hills');
     $address->setState('NSW');
     $address->setCountry('AU');
     $address->setPostcode(2010);
     $address->setPhone('0212345678');
     $address->setType($type);
     $address->save();
     return $address->getId();
 }
コード例 #4
0
 /**
  * Run a test, and update if nescessary on the user address data.
  *
  * @param rtGuardUser $user
  * @param string      $type
  * @param rtAddress   $address
  */
 private function updateUserAddressInfo(rtGuardUser $user, $type, rtAddress $new_address)
 {
     $address = Doctrine::getTable('rtAddress')->getAddressForObjectAndType($user, $type);
     if (!$address) {
         $address = $new_address->copy(false);
         $address->setModel('rtGuardUser');
         $address->setModelId($user->getId());
         $address->save();
     }
 }