【发布时间】:2014-04-03 10:22:20
【问题描述】:
我对 codeigniter 很陌生。我的问题是在提交账单和送货地址后我如何重定向到 paypal。我的意思是有什么方法可以从控制器重定向/表单提交。下面是我在控制器中的下单功能
function place_order()
{
if ($this->input->server('REQUEST_METHOD') === 'POST')
{
$this->form_validation->set_rules('bill_first_name', 'First Name', 'trim|required');
$this->form_validation->set_rules('bill_last_name', 'Last Name', 'trim|required');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('address', 'Address', 'trim|required');
$this->form_validation->set_rules('phone', 'Phone', 'trim|required');
if ($this->form_validation->run())
{
$data_to_store = array(
'bill_first_name' => $this->input->post('bill_first_name'),
'bill_last_name' => $this->input->post('bill_last_name'),
'email' => $this->input->post('email'),
'address' => $this->input->post('address'),
'phone' => $this->input->post('phone'),
'country' => $this->input->post('country'),
'city' => $this->input->post('city'),
'zip' => $this->input->post('zip'),
'user_id' => $this->session->userdata('sess_user_id'),
'session_id' => $this->session->userdata('session_id'),
'create_date' => date('Y-m-d H:i:s')
);
$customer=$this->checkout_model->add_user('tbl_customer',$data_to_store);
if($customer){
$data = array(
'customer_id' => $customer,
'user_id' => $this->session->userdata('sess_user_id'),
'session_id' => $this->session->userdata('session_id'),
'create_date' => date('Y-m-d H:i:s')
);
$order=$this->checkout_model->add_user('tbl_order',$data);
if($order)
{
if ($cart = $this->cart->contents()):
foreach ($cart as $item):
$order_detail = array(
'order_id' => $order,
'product_id' => $item['id'],
'qty' => $item['qty'],
'product_price' => $item['price'],
'sub_total' => $item['qty'] * $item['price']
);
$cust_id = $this->checkout_model->add_user('tbl_order_details',$order_detail);
endforeach;
endif;
}
$this->cart->destroy();
}
paypallllllllllllllllllllllll
}
}
【问题讨论】:
标签: codeigniter