Post by maly3900 » Fri Oct 19, 2018 3:44 am

Hi all. At first - im totally new in OpenCart system.... True beginner :(
Anyway, I've done my first modules, simple codes, etc

Now Im in big challange - from simple page at PHP code I need to add new customer.
I found at libs function addCustomer($data).

When I tried this:

Code: Select all

 $nowykustomer = array(
'customer_group_id' => 1,
'store_id' => 0,
'language_id' => (int)$this->config->get('config_language_id'),
 'firstname' => "Kodowy",
 'lastname' => "Programistyczny",
 'email' => "mail@utworzony.przez.skrypt",
 'telephone' => 112903201,
 'password' => "password"
  'ip' => $_SERVER['REMOTE_ADDR']
  );
$this->customer->addCustomer($nowykustomer);
I see error500 (i guess - at bad codding OpenCart show this error number).


Sooo... im beg all of You - help me, please. I freaky don't know how to deal with problem. I tried so many $data and always is the same result...
What I do wrong?... Well big THX for helping ??? ;D

Edit: I'm using newest OpenCart... Soo... I've tried every options and... propably to solve my problem is simple using MySQL action. I'm right?

Code: Select all

INSERT INTO `oc_customer` ........
Next edit: Yeap. I was tired of thinking about function addCustomer and I use simple MySQL query. In case if U wonder...

Code: Select all

$this->db->query("INSERT INTO `oc_customer` (`customer_id`, `customer_group_id`, `store_id`, `language_id`, `firstname`, `lastname`, `email`, `telephone`, `fax`, `password`, `salt`, `cart`, `wishlist`, `newsletter`, `address_id`, `custom_field`, `ip`, `status`, `safe`, `token`, `code`, `date_added`) VALUES (NULL, '1',".(int)$this->config->get('config_store_id').",".(int)$this->config->get('config_language_id').", 'FIRSTNAME', 'LASTNAME', 'E-M@IL.DOT.COM', 'TELEPHONE', '', 'MD5-HASH-PASSWORD', 'SALT-FOR-PASSWORD', NULL, NULL, '1', '1', '', '".$_SERVER['REMOTE_ADDR']."', '1', '0', '', '', '0000-00-00 00:00:00')");
Ofc, date you can set with simple date; param in php

Bless You all :)

Newbie

Posts

Joined
Mon Aug 13, 2018 9:42 pm

Post by straightlight » Sun Oct 21, 2018 1:33 am

Replace:

Code: Select all

'password' => "password"
with:

Code: Select all

'password' => "password",
As for the remote IP address, since you've already defined the array key, there's no need to re-use the same superglobal REMOTE_ADDR in the database but rather use the array key name: 'ip' with your assigned array in the method's parameter.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by maly3900 » Sun Oct 21, 2018 10:42 pm

Emmm... what a freaking typo! But, this dosen't work too. Again I've got 500 error. How to use addCustomer function?...
I don't get it... MySQL query is simple solution but with update of OpenCart this can be out of date... Dang, this script is simple hard and there's no good specification on web... ehhh. This is extreme task for me.

Newbie

Posts

Joined
Mon Aug 13, 2018 9:42 pm

Post by straightlight » Sun Oct 21, 2018 11:43 pm

Emmm... what a freaking typo! But, this dosen't work too. Again I've got 500 error.
What does that explain? More information is needed. Forum rules.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by maly3900 » Mon Oct 22, 2018 12:25 am

Sorry for my mayhem post, I have angry issue with this "piece of cake" :D

So, I've edited my code with Your prompt

Code: Select all

'password' => "password"
to

Code: Select all

'password' => "password",
but script doesnt work. Again I see 500 error. What that explain? Hmmm... propably I doing something wrong. I dunno waht. Theoretically my problem is solved with MySQL query...but, I dont wanna do this with"manual" query but with OpenCart functions. I dont get it... :<
At last, my question is, how to use OpenCart function addCustomer? I know - it is a array of datas, but all the time when I use it - ive got an 500 error and in MySQL database noting happen.

Newbie

Posts

Joined
Mon Aug 13, 2018 9:42 pm

Post by straightlight » Mon Oct 22, 2018 12:57 am

maly3900 wrote:
Mon Oct 22, 2018 12:25 am
Sorry for my mayhem post, I have angry issue with this "piece of cake" :D

So, I've edited my code with Your prompt

Code: Select all

'password' => "password"
to

Code: Select all

'password' => "password",
but script doesnt work. Again I see 500 error. What that explain? Hmmm... propably I doing something wrong. I dunno waht. Theoretically my problem is solved with MySQL query...but, I dont wanna do this with"manual" query but with OpenCart functions. I dont get it... :<
At last, my question is, how to use OpenCart function addCustomer? I know - it is a array of datas, but all the time when I use it - ive got an 500 error and in MySQL database noting happen.
First, nobody gets angry with piece of cakes except for diabetic people and, even there, it's not their fault. It is a tasty ingredient when you do know how to make it.

You are absolutely right, you are doing something wrong, you did not posted your error / server access logs based on this error 500 event. Forum rules.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by maly3900 » Fri Oct 26, 2018 7:58 pm

After hardthinking about this problem I already have solve :) here is code:

Code: Select all

 $nowykustomer = array(
'customer_group_id' => 1,
'store_id' => 0,
'language_id' => (int)$this->config->get('config_language_id'),
'firstname' => "Imie",
'lastname' => "Nazwisko",
'email' => "mail@mail.pl",
'telephone' => 0700882123,
'password' => "password",
'ip' => $_SERVER['REMOTE_ADDR']
);
$this->load->model('account/customer');
$this->model_account_customer->addCustomer($nowykustomer);
Wishes

Newbie

Posts

Joined
Mon Aug 13, 2018 9:42 pm
Who is online

Users browsing this forum: No registered users and 162 guests