beaudenheijer Posted January 13, 2019 Share Posted January 13, 2019 Good evening, I'm currently developing a website for a company. I've been using prestashop since 2 weeks ago. but some here and there are a little to complicated. right now where im stuck at is by adding an address after a creation of the customer in the registration panel. currently my code look this: include_once('../config/config.inc.php'); include_once('../init.php'); $context = Context::getContext(); $default_lang = Configuration::get('PS_LANG_DEFAULT'); try { if (isset($_POST['email'], $_POST['voornaam'], $_POST['achternaam'], $_POST['wachtwoord'], $_POST['birthDay'], $_POST['birthMonth'], $_POST['birthYear'], $_POST['gender'])) { // initializing customer $customer = new Customer(); if ($customer->getByEmail($_POST['email'], $_POST['wachtwoord'])) { echo "user already exist"; return; } // initializing customer details $customer->id = 1; $customer->email = $_POST['email']; $customer->lastname = $_POST['achternaam']; $customer->firstname = $_POST['voornaam']; $customer->passwd = $_POST['wachtwoord']; $customer->id_gender = $_POST['gender.'] === 'Dhr.' ? 0 : 1; $customer->birthday = $_POST['birthYear'] . '-' . $_POST['birthMonth'] . '-' . $_POST['birthDay']; // adding the customer $customer->add(); if(isset($_POST['adres'], $_POST['number'], $_POST['zip'], $_POST['city'], $_POST['phone_number'])) { $address = new CustomerAddress(); $address->id = 1; $address->id_customer = $customer->id; $address->firstname =$customer->firstname; $address->lastname = $customer->lastname; $address->city = $_POST['city']; $address->postcode = $_POST['zip']; $address->phone = $_POST['phone_number']; $address->address1 = $_POST['adres'] . ' ' . $_POST['number']; $address->address2 = ''; $address->alias = 'Home'; $address->add(); $customer->update(); } } } catch(PrestaShopException $e) { echo $e; } as you can see in the back-end of prestashop you can see a (test user) has been made. but as you can see down to the bottom that there is nothing while i said in the code to add the address on the customers id. It would be nice that it could be fixed or something that i missed. I wish you all a nice evening, Yours faithfully, Beau Link to comment Share on other sites More sharing options...
beaudenheijer Posted January 14, 2019 Author Share Posted January 14, 2019 (edited) the part: $address->add(false, false); doesn't work i've pute an echo before and after. before it printed and after it didn't do anything and im currently running on 1.7.4.2 Edited January 14, 2019 by beaudenheijer (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now