Jump to content

Who acquired who? Referral Program!


Recommended Posts

Hello, I just installed the new 1.6.0.6 and have a little problem with the referral program module.


 


If John Doe recruits 3 friends, I'm not able to find any info that it was John Doe that referred them.


 


I need this info because if John Doe recruits 10 paying friends he will receive some gifts.


 


I know this info was possible to see in the earlier versions under the "Customers info" but now it's gone.


Any idea where it's gone?


 


Hope someone understand my question.  :D


 


 


 


Have a great day!


 


Regards// Tobias


Link to comment
Share on other sites

Hello, in the 1.5.3.1.

 

Under the customers info you could scroll down and see this 

 

(see pic) 

referral.jpg

It's in Swedish but it means:

"No one have sponsored this customer.
Tobias Karlsson have not yet referred any customer"

 

However this is not shown in the 1.6.0.6 version.

 

Hope you understand.

 

// Tobias 

Link to comment
Share on other sites

have you received any answer about this somewhere else?

No, still not working. Tried comparing the original 1.6 files for this module with the ones on my server and I can't see any difference so I'm thinking the problem lies somewhere outside the module folder. I could be wrong though.

 

What I thought was strange was there is only a folder for the referral module in the Themes module folder and not the other modules folder. The other thing that I thought was odd was there was only a Front folder in the templates folder and I would have expected a Back folder so that actually may be somewhere else that I can't find and may be where the problem lies.

Link to comment
Share on other sites

  • 2 months later...

I had the same issue, and checking the code I found that the problem was in the file /modules/referralprogram/referralprogram.php, in the function hookAdminCustomers.

 

For any reason, it generates the referral information and assign it to a template that not exists (hook_customers_16.tpl or hook_customers.tpl if your PS version is lower than 1.6). I've checked the code on github and in the PS 1.5.6.2 (the last before 1.6), and before it version, the module worked directly returning the html to the hook, but in 1.6 it was changed to the template system, with a little detail, the tpl file does not exist! (hook_customers_16.tpl or hook_customers.tpl), Neither in the prestashop download files, or in github referralprogram files or github commits, it's really strange.

I've fixed it in my case, replacing the hookAdminCustomers function of file  /modules/referralprogram/referralprogram.php with a little modified version of the PS 1.5.6.2 hook, mainly display modifications. 

I've tested it and it seems to work, at least it shows the counter of the sponsored customers, registration dates, if the sponsored is registered or not, order placed, name, email, and if somebody has sponsored the current user.

To fix it replace the whole hookAdminCustomers function ( public function hookAdminCustomers($params) ) on referralprogram.php with the next code:
 

	public function hookAdminCustomers($params)
	{
		include_once(dirname(__FILE__).'/ReferralProgramModule.php');

		$customer = new Customer((int)$params['id_customer']);
		if (!Validate::isLoadedObject($customer))
			die ($this->l('Incorrect Customer object.'));

		$friends = ReferralProgramModule::getSponsorFriend((int)$customer->id);
		if ($id_referralprogram = ReferralProgramModule::isSponsorised((int)$customer->id, true))
		{
			$referralprogram = new ReferralProgramModule((int)$id_referralprogram);
			$sponsor = new Customer((int)$referralprogram->id_sponsor);
		}

		$html = '
		<br />
		<h2>'.$this->l('Referral program').' ('.count($friends).' invited friends)</h2>
		<h3 style="margin:1px 5px;">'.(isset($sponsor) ? $this->l('Customer\'s sponsor:').' <a href="index.php?tab=AdminCustomers&id_customer='.(int)$sponsor->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id).'">'.$sponsor->firstname.' '.$sponsor->lastname.'</a>' : $this->l('No one has sponsored this customer.')).'</h3>';

		if ($friends AND sizeof($friends))
		{
			$html.= '<h3 style="margin:1px 5px;">'.sizeof($friends).' '.(sizeof($friends) > 1 ? $this->l('Sponsored customers:') : $this->l('Sponsored customer:')).'</h3>';
			$html.= '
		<table cellspacing="0" cellpadding="0" class="table">
			<tr style="background-color:#F5E9CF; padding: 0.3em 0.1em;">
					<th class="center">'.$this->l('ID').'</th>
					<th class="center">'.$this->l('Name').'</th>
					<th class="center">'.$this->l('Email').'</th>
					<th class="center">'.$this->l('Registration date').'</th>
					<th class="center">'.$this->l('Customers sponsored by this friend').'</th>
					<th class="center">'.$this->l('Placed orders').'</th>
					<th class="center">'.$this->l('Customer account created').'</th>
				</tr>';
				foreach ($friends AS $key => $friend)
				{
					$orders = Order::getCustomerOrders($friend['id_customer']);
					$html.= '
					<tr '.($key++ % 2 ? 'class="alt_row"' : '').' '.((int)($friend['id_customer']) ? 'style="cursor: pointer" onclick="document.location = \'?tab=AdminCustomers&id_customer='.$friend['id_customer'].'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)$this->context->employee->id).'\'"' : '').'>
						<td class="center">'.((int)($friend['id_customer']) ? $friend['id_customer'] : '--').'</td>
						<td>'.$friend['firstname'].' '.$friend['lastname'].'</td>
						<td>'.$friend['email'].'</td>
						<td>'.Tools::displayDate($friend['date_add'],null , true).'</td>
						<td align="right">'.sizeof(ReferralProgramModule::getSponsorFriend($friend['id_customer'])).'</td>
						<td align="right">'.($orders ? sizeof($orders) : 0).'</td>
						<td align="center">'.((int)$friend['id_customer'] ? '<img src="'._PS_ADMIN_IMG_.'enabled.gif" />' : '<img src="'._PS_ADMIN_IMG_.'disabled.gif" />').'</td>
					</tr>';
				}
			$html.= '
				</table>';
		}
		else
			$html.= sprintf($this->l('%1$s %2$s has not sponsored any friends yet.'), $customer->firstname, $customer->lastname);
		return $html;
	}

Hope it helps.
Daniel

  • Like 3
Link to comment
Share on other sites

×
×
  • Create New...