I have created the following code (CODE1) which is working very good and save my custom field. Unfortunately my other code (CODE2) which doing the same thing is not working. Do you have any idea what is going wrong?
CODE 1
Code: Select all
public function assignaccount() {
if(isset($this->request->get['login'])){
$data['email'] = $this->customer->getEmail();
$this->load->model('account/customer');
$customer_info = $this->model_account_customer->getCustomerByEmail($this->customer->getEmail());
if($customer_info){
$custom_field = json_decode($customer_info['custom_field']);
$cust = array();
foreach($custom_field as $key=>$c){
$cust[$key] = $c;
if($key == 11){
$cust[$key] = $this->request->get['login'];
}
}
$this->db->query("UPDATE " . DB_PREFIX . "customer SET custom_field = '" . $this->db->escape(json_encode($cust))."' WHERE LCASE(email) = '" . $this->db->escape(utf8_strtolower($this->customer->getEmail())) . "'");
Code: Select all
public function assignaccounteur() {
if(isset($this->request->get['login'])){
$data['email'] = $this->customer->getEmail();
$this->load->model('account/customer');
$customer_info = $this->model_account_customer->getCustomerByEmail($this->customer->getEmail());
if($customer_info){
$custom_field = json_decode($customer_info['custom_field']);
$cust = arrayeuro();
foreach($custom_field as $key=>$c){
$cust[$key] = $c;
if($key == 12){
$cust[$key] = $this->request->get['login'];
}
}
$this->db->query("UPDATE " . DB_PREFIX . "customer SET custom_field = '" . $this->db->escape(json_encode($cust))."' WHERE LCASE(email) = '" . $this->db->escape(utf8_strtolower($this->customer->getEmail())) . "'");