/**
  * get customer list
  * @param $site_srl
  * @param array $extraParams
  * @return array
  * @throws ShopException
  */
 public function getCustomersList($site_srl, array $extraParams = array())
 {
     if (!$site_srl) {
         throw new ShopException("Missing arguments for get customers list : please provide [site_srl]");
     }
     $addressRepository = new AddressRepository();
     $page = Context::get('page') ? Context::get('page') : 1;
     $output = $this->getSiteMemberList($site_srl, $page, $extraParams);
     foreach ($output->data as $member) {
         $customer = new Customer($member);
         $customer->addresses = $addressRepository->getAddresses($customer->member_srl);
         $customer->telephone = $customer->addresses->default_billing->telephone;
         $customer->postal_code = $customer->addresses->default_billing->postal_code;
         $customer->country = $customer->addresses->default_billing->country;
         $customer->region = $customer->addresses->default_billing->region;
         $extra_vars = unserialize($member->extra_vars);
         $customer->newsletter = $extra_vars->newsletter;
         $customers[] = $customer;
     }
     $output->customers = $customers;
     return $output;
 }
예제 #2
0
 /**
  * @expectedException PromisePay\Exception\Argument
  */
 public function testGetAddressByIdMissedId()
 {
     $address = new AddressRepository();
     $missed = '';
     $address->getAddressById($missed);
 }
예제 #3
0
 /**
  * Saves or updates the object
  * @return mixed|object
  */
 public function save()
 {
     return $this->address_srl ? $this->repo->update($this) : $this->repo->insert($this);
 }
예제 #4
0
 /**
  * @return Address|null
  */
 public function getShippingAddress()
 {
     if (is_numeric($this->shipping_address_srl)) {
         $aRepo = new AddressRepository();
         return $aRepo->getAddress($this->shipping_address_srl);
     } else {
         $addresses = $this->getAddresses();
         if (!$addresses || empty($addresses)) {
             return null;
         }
         $defaultShippingAddress = null;
         /** @var $address Address */
         foreach ($addresses as $address) {
             if ($this->shipping_address_srl == $address->address_srl) {
                 return $address;
             }
             if ($address->isDefaultShippingAddress()) {
                 $defaultShippingAddress = $address;
             }
         }
         return $defaultShippingAddress;
     }
 }