Warning: made a backup of the file prior to modify them!
File "themes/NOME_DEL_TEMA/authentication.tpl "
Add this lines in the point where you want:
Codice: Seleziona tutto
<p class="text">
<label for="referralcode">{l s='Referral code'}</label>
<input name="referralcode" type="text" class="text" id="referralcode" />
</p>
File "controllers/front/AuthController.php"
About line 390, find the code:
Codice: Seleziona tutto
// Preparing customer
$customer = new Customer();
$lastnameAddress = Tools::getValue('lastname');
$firstnameAddress = Tools::getValue('firstname');
After, add:
Codice: Seleziona tutto
$referralCode = Tools::getValue('referralcode');
Codice: Seleziona tutto
$customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);
if (!Validate::isBirthDate($customer->birthday))
$this->errors[] = Tools::displayError('Invalid date of birth.');
Codice: Seleziona tutto
$customer->referralcode = $referralCode;
Codice: Seleziona tutto
$customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']);
if (!Validate::isBirthDate($customer->birthday))
$this->errors[] = Tools::displayError('Invalid date of birth');
Codice: Seleziona tutto
$customer->referralcode = $referralCode;
Codice: Seleziona tutto
$this->context->customer = $customer;
$this->context->smarty->assign('confirmation', 1);
$this->context->cookie->id_customer = (int)$customer->id;
Codice: Seleziona tutto
$this->context->cookie->customer_referralcode = $customer->referralcode;
File "class/Customer.php"
About line 30, find the code:
Codice: Seleziona tutto
public $id;
Codice: Seleziona tutto
/** @var string Referralcode */
public $referralCode;
If you are using translation file, available on the folder "themes/NOME_DEL_TEMA/lang", add following two lines:
Codice: Seleziona tutto
$_LANG['authentication-create-account_1b4033814553ad8ffb709e3b5cc6ee2c'] = 'INSERIRE_QUI_LA_TRADUZIONE';
$_LANG['authentication_1b4033814553ad8ffb709e3b5cc6ee2c'] = 'INSERIRE_QUI_LA_TRADUZIONE';
In order to show the field in the customer list within the Administration section, please modify the file "controllers/admin/AdminCustomersController.php"
About line 143, find the code:
Codice: Seleziona tutto
'connect' => array(
'title' => $this->l('Last visit'),
'width' => 100,
'type' => 'datetime',
'search' => false,
'havingFilter' => true
)
);
Codice: Seleziona tutto
'connect' => array(
'title' => $this->l('Last visit'),
'width' => 100,
'type' => 'datetime',
'search' => false,
'havingFilter' => true
),
'referralcode' => array(
'title' => $this->l('Referral code'),
'width' => 'auto',
'search' => true
)
);
Alter the database (if you are using the table suffix "ps" the table is `ps_customer`):
Codice: Seleziona tutto
ALTER TABLE `ps_customer`
ADD `referralcode` VARCHAR( 100 )
How Neller indicate me, I have missed a step!
Thank you Neller.in classes/Customer.php
around line 160
public static $definition = array(
...
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32),
Below this line, add this line
'referralcode' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),