コード例 #1
0
 public function addUserAddressAction()
 {
     header('Content-type: text/plain; charset=utf-8');
     header('Cache-Control: no-store, no-cache');
     header('Expires: ' . date('r'));
     $userId = Validate::validateInputVar('userid', 'INPUT_POST', 'int');
     $address = Validate::validateInputVar('address', 'INPUT_POST', 'str');
     $postal = Validate::validateInputVar('postal', 'INPUT_POST', 'str');
     if (!(empty($address) && $userId)) {
         $model = new AddressTableModel($userId, [$address], [$postal]);
         echo $model->addRecord();
     }
 }
コード例 #2
0
 public function getAddress()
 {
     $userAddressId = $this->order->getUserAddress();
     if (!empty($userAddressId) && $userAddressId != 0) {
         $addressModel = new AddressTableModel($this->order->getUserId());
         $addressModel->setTable('address');
         $address = $addressModel->readRecordsById()[0];
         return $address['address'] . ', Индекс: ' . $address['postal_code'];
     } else {
         $mode = $this->order->getRememberAddress();
         if ($mode && $mode == 1) {
             $addressModel = new AddressTableModel($this->order->getUserId(), [$this->order->getFullAddress()], [$this->order->getPostal()]);
             $flag = $addressModel->checkAddress($this->order->getFullAddress());
             if (!$flag) {
                 $addressModel->addRecord();
             }
         }
         if (!is_null($this->order->getFullAddress())) {
             return $this->order->getFullAddress() . ', Индекс: ' . $this->order->getPostal();
         } else {
             return NULL;
         }
     }
 }