예제 #1
0
 public function action_customer()
 {
     $customer_id = $this->request->param('id');
     $customer_lookup = new Beans_Customer_Lookup($this->_beans_data_auth((object) array('id' => $customer_id)));
     $customer_lookup_result = $customer_lookup->execute();
     if ($this->_beans_result_check($customer_lookup_result)) {
         $this->_view->customer_lookup_result = $customer_lookup_result;
         $this->_action_tab_name = $customer_lookup_result->data->customer->display_name;
         $this->_action_tab_uri = '/' . $this->request->uri();
         $customer_address_search = new Beans_Customer_Address_Search($this->_beans_data_auth((object) array('search_customer_id' => $customer_id)));
         $customer_address_search_result = $customer_address_search->execute();
         if ($this->_beans_result_check($customer_address_search_result)) {
             $this->_view->customer_address_search_result = $customer_address_search_result;
         }
         $customer_sale_search = new Beans_Customer_Sale_Search($this->_beans_data_auth((object) array('search_customer_id' => $customer_id, 'page_size' => 5, 'sort_by' => 'newest', 'search_and' => TRUE)));
         $customer_sale_search_result = $customer_sale_search->execute();
         if ($this->_beans_result_check($customer_sale_search_result)) {
             $this->_view->customer_sale_search_result = $customer_sale_search_result;
         }
     }
 }
예제 #2
0
파일: json.php 프로젝트: rrsc/beansbooks
 function action_customeraddressupdate()
 {
     $customer_address_update = new Beans_Customer_Address_Update($this->_beans_data_auth((object) array('id' => $this->request->post('address_id'), 'address1' => $this->request->post('address1'), 'address2' => $this->request->post('address2'), 'city' => $this->request->post('city'), 'state' => $this->request->post('state'), 'zip' => $this->request->post('zip'), 'country' => $this->request->post('country'))));
     $customer_address_update_result = $customer_address_update->execute();
     if (!$customer_address_update_result->success) {
         return $this->_return_error("An error occurred in creation your address:<br>" . $this->_beans_result_get_error($customer_address_update_result));
     }
     $customer_result = FALSE;
     if ($this->request->post('default-billing') or $this->request->post('default-shipping')) {
         $customer_update_data = new stdClass();
         $customer_update_data->id = $this->request->post('customer_id');
         if ($this->request->post('default-billing')) {
             $customer_update_data->default_billing_address_id = $customer_address_update_result->data->address->id;
         }
         if ($this->request->post('default-shipping')) {
             $customer_update_data->default_shipping_address_id = $customer_address_update_result->data->address->id;
         }
         $customer_update = new Beans_Customer_Update($this->_beans_data_auth($customer_update_data));
         $customer_result = $customer_update->execute();
     } else {
         $customer_lookup = new Beans_Customer_Lookup($this->_beans_data_auth((object) array('id' => $this->request->post('customer_id'))));
         $customer_result = $customer_lookup->execute();
     }
     if (!$customer_result) {
         return $this->_return_error("An unknown error has occurred.");
     }
     if (!$customer_result->success) {
         return $this->_return_error($this->_beans_result_get_error($customer_result));
     }
     $address = $customer_address_update_result->data->address;
     $html = new View_Partials_Customers_Customer_Address();
     $html->address = $customer_address_update_result->data->address;
     $html->customer = $customer_result->data->customer;
     $address->html = $html->render();
     $address->default_billing = $this->request->post('default-billing') ? TRUE : FALSE;
     $address->default_shipping = $this->request->post('default-shipping') ? TRUE : FALSE;
     $this->_return_object->data->address = $address;
 }