Jump to content

[SOLVED] Error when re-saving the address during OPC!


Recommended Posts

First of all, I'd like to thank the Prestashop team for an amazing job on the 1.5 version. Been waiting so long and it has been a joy getting it ready for my customers!

 

Naturally, there aren't many posts on this version yet, which is why I'm posting this on one error that I keep receiving.

 

Basically, whenever I fill in my information in the OPC form for guests (i only have the option of checking out as a guest), and save it, everthing is fine. But if I wish to change a detail and save it again, I get the error "There is 1 error(s): The alias "My address" is already used, please chose another one."

 

Now I dont know very much about this vast system, but I have spent a couple of days trying to figure it out.

 

I know that there is a hidden input box called "alias" that I basically have to unhide and change the value from the standard "My address" to something else to be able to resave the form. The solution I can see is to somehow maybe add a random string of letters to the value if this error occurs. I think you do this in the AddressController.php, and I think it is the following piece of code at line 174 that needs to be altered, but I'm not sure and I dont have the faintest clue of what to alter it to. My trial and error-testing for the past few days hasn't worked out ^^

 

 

 

// Check if the alias exists
if (!empty($_POST['alias'])
&& (int)$this->context->customer->id > 0
&& Db::getInstance()->getValue('
SELECT count(*)
FROM '._DB_PREFIX_.'address
WHERE `alias` = \''.pSql($_POST['alias']).'\'
AND id_address != '.(int)Tools::getValue('id_address').'
AND id_customer = '.(int)$this->context->customer->id.'
AND deleted = 0') > 0)
$this->errors[] = sprintf(Tools::displayError('The alias "%s" is already used, please chose another one.'), Tools::safeOutput($_POST['alias']));

 

Obviously adding a random string of letters and numbers wouldnt look nice if the customer can see the input box for alias, but then again the customer who would see it would actively rename the address himself/herself and would therefore not be a guest user, but a registered one. So this would only apply for a guest customer of course.

 

I am currently using version 1.5.0.17 and I have themed the website myself based on the default theme. However, this error occurs on a newly installed version without any alterations as well.

 

The address to the website is http://thebowclub.com/shop/

 

Dont know if I have left anything out, so tell me if I need to supply more info!

Edited by mnsaleem (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 5 months later...

Hello!

 

I have attached the file that was changed. It should go into controllers/front/

 

I have the same error here, Prestashop 1.5.3.1!

 

Opplied your AddressController.php but it still doesn't work. Can you also provide OrderOpcController.php please?

Link to comment
Share on other sites

×
×
  • Create New...