I am struggling with modifying some code in Customer registration management module. Instant checkout is not working the way it should. When the Customer registration management module is disabled, the Instant Checkout is working fine, on submit and with no errors we go to the next step/screen. When Customer registration module is enabled, once we click on submit button under Instant checkout, we do not go to the next step/screen, instead we come back to the same screens, forms empty, and in url we have this: authentication?back=order.php%3Fstep%3D1
I managed to identify a piece a code which is preventing a customer from going to the following screen from Instant checkout form. It is the code in function hookCreateAccount($params)
function hookCreateAccount($params)
{
require_once (dirname(__FILE__).'/ApprovedCustomer.php');
global $cookie, $back;
$registration_code = pSQL(Tools::getValue('registration_code'));
if ($registration_code != '' AND $registration_code == $this->_registrationCode) {
$customer = $params['newCustomer'];
$customer->cleanGroups();
$customer->addGroups ($this->_defaultGroups);
}
$cookie->logged = $this->_isCustomerRegistredByDefault;
$cust = $params['newCustomer'];
$approval = new ApprovedCustomer($cust->id);
$approval->is_approved = $this->_isCustomerRegistredByDefault;
$approval->privilege_request = intval(Tools::getValue('privilege_request'),0);
$approval->privilege_message = pSQL(Tools::getValue('privilege_message'), '');;
if (! $approval->save())
Tools::D('Unable to save approval information');
if ($this->_sendAdminMail)
$this->sendMail('pending_registration', array('customer' => $cust, 'approval'=>$approval));
if (! $approval->is_approved) {
$back = 'modules/'.basename(__FILE__, '.php').'/messages.php?msg=noconnect&back=my-account.php';
$cookie->logged = 0;
$cookie->id_customer = 0;
}
elseif ($back == '')
$back = 'my-account.php';
}
Anybody has any ideas what in this code is causing this? any help would be really appreciated.
exactly what happens: once the user fill in Instant checkout form and clicks on submit, the form is redirected to the same page: … /authentication?back=order.php%3Fstep%3D1
but it should go to: /order?step=2
the Instant Checkout form action:
<form action="{$link->getPageLink('authentication.php', true)}?back={$back}" method="post" id="new_account_form" class="std">
so, should I change the action part then? how does this work? could somebody point me to the right direction? any help would be really appreciated.
I suspect that the conflict occurs because by definition your customer isn’t registering as part of the One Page Checkout functionality (I assume this is what you mean by Instant Checkout).
You could try refactoring the first block of code as: