Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Include Referral on Admin/index.php


Mort-lemur

Recommended Posts

Hi,

 

I Use the rhm referral mod on my 2.2 stores - this mod asks customers to select where they heard about us when signing up for an account - and it works great - showing me the referral sources in admin/reports and admin/customers.

 

However, to give me a "real time" view of referrals to my site for new customers I would like to add the referral source next to the customers name in admin/index.php but am struggling with a part of the change if anyone can help.

 

In admin/includes/modules/index.php I have added :

 

 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_REFERRED_BY; //rmh referral ?></td>  

which adds the column heading, with a corresponding entry in the language file.

 

I have also included the query to pull the data from the database as follows:

 

//rmh referral start
  $source_query = tep_db_query("select customers_info_source_id  from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . $customers['customers_id'] . "'");
  $source = tep_db_fetch_array($source_query);
  $entry_referral = tep_get_sources_name($source['customers_info_source_id'], $customers['customers_id']);
//rmh referral end

 

However, I cant seem to get the code right for echo'ing the data next to the customers name / date in the column, the code I need to insert is something like this:

		   <td class="dataTableContent" align="right"><?php echo $entry_referral; //rmh referral ?></td>

and I need to insert it somehow into the end of this block of code:

  echo '  <tr class="dataTableRow" onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);">' .
	 '    <td class="dataTableContent"><a href="' . tep_href_link(FILENAME_CUSTOMERS, 'cID=' . (int)$customers['customers_id'] . '&action=edit') . '">' . tep_output_string_protected($customers['customers_firstname'] . ' ' . $customers['customers_lastname']) . '</td>' .
	 '    <td class="dataTableContent">' . $customers['customers_info_date_account_created'] . '</td>' .
	 '  </tr>';
 }
?>
</table>

 

But cant seem to achieve the desired effect - any help would be fantastic thanks.

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

@@Mort-lemur

 

	 echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);">' .
			 '	 <td class="dataTableContent"><a href="' . tep_href_link(FILENAME_CUSTOMERS, 'cID=' . (int)$customers['customers_id'] . '&action=edit') . '">' . tep_output_string_protected($customers['customers_firstname'] . ' ' . $customers['customers_lastname'] . ' Referral: ' . $entry_referral) . '</td>' .
			 '	 <td class="dataTableContent">' . $customers['customers_info_date_account_created'] . '</td>' .
			 ' </tr>';
}
?>
</table>

 

or in its own <td>

 

	 echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);">' .
			 '	 <td class="dataTableContent"><a href="' . tep_href_link(FILENAME_CUSTOMERS, 'cID=' . (int)$customers['customers_id'] . '&action=edit') . '">' . tep_output_string_protected($customers['customers_firstname'] . ' ' . $customers['customers_lastname']) . '</td>' .
'<td class="dataTableContent" align="right">' . $entry_referral . '</td>' .
			 '	 <td class="dataTableContent">' . $customers['customers_info_date_account_created'] . '</td>' .
			 ' </tr>';
}
?>
</table>

Matt

Link to comment
Share on other sites

@@mattjt83 Thank you for that Matt, that inserts the referral source just where I wanted it.

 

However, there appears to be a problem with the query which pulls the referal source from the database - as all the referral sources are appearing as "-none-" which is confusing me a little, as it is exactly the same query as used in admin/customers.php

 

Thanks for anything you can suggest

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

@@Mort-lemur

 

$customers['customers_id']

Might not be available on the page you are viewing because it was also generated from a db query. You will have to grab that from another query in order to use it to then grab the referral info.

Matt

Link to comment
Share on other sites

@@mattjt83 Thanks again matt, tried several variations of grabbing the customer_id with my latest iteration being as follows:

 

//rmh referral start
  $source_query = tep_db_query("select ci.customers_info_source_id, c.customers_id  from " . TABLE_CUSTOMERS_INFO ." ci, " .  TABLE_CUSTOMERS . " c where customers_info_id = '" . $customers['customers_id'] . "'");
  $source = tep_db_fetch_array($source_query);
  $entry_referral = tep_get_sources_name($source['customers_info_source_id'], $customers['customers_id']);
//rmh referral end

 $customers_query = tep_db_query("select c.customers_id, c.customers_lastname, c.customers_firstname, ci.customers_info_date_account_created from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id order by ci.customers_info_date_account_created desc limit 20");
 while ($customers = tep_db_fetch_array($customers_query))  {
  echo '  <tr class="dataTableRow" onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);">' .
	 '    <td class="dataTableContent"><a href="' . tep_href_link(FILENAME_CUSTOMERS, 'cID=' . (int)$customers['customers_id'] . '&action=edit') . '">' . tep_output_string_protected($customers['customers_firstname'] . ' ' . $customers['customers_lastname']) . '</td>' .
	 '    <td class="dataTableContent">' . $customers['customers_info_date_account_created'] . '</td>' .
  '<td class="dataTableContent" align="right">' . $entry_referral . '</td>' .
	 '  </tr>';
 }
?>
</table>

 

Still showing referral source as -none-

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

@@mattjt83 Sorry Matt - I dont understand that line of code - especially as orders has crept into it - Im trying to show the referral sources of customers who have regestered, regardless if they have raised an order or not.

 

Thanks

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

The extra line of SQL code, it does nothing and adds nothing. Hence you get -none-.

 

Ill never get any more answers to my questions if Im not careful here

This comment is interesting. Can this be because most of the more "technical" questions are mainly answered by people who are developers?

Link to comment
Share on other sites


$customers_query = tep_db_query("select c.customers_id, c.customers_lastname, c.customers_firstname, ci.customers_info_date_account_created, ci.customers_info_source_id from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id order by ci.customers_info_date_account_created desc limit 20");
 while ($customers = tep_db_fetch_array($customers_query))  {
         echo '  <tr class="dataTableRow" onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);">' .
                '      <td class="dataTableContent"><a href="' . tep_href_link(FILENAME_CUSTOMERS, 'cID=' . (int)$customers['customers_id'] . '&action=edit') . '">' . tep_output_string_protected($customers['customers_firstname'] . ' ' . $customers['customers_lastname']) . '</td>' .
                '      <td class="dataTableContent">' . $customers['customers_info_date_account_created'] . '</td>' .
                '      <td class="dataTableContent">' . $customers['customers_info_source_id'] . '</td>' .
                '  </tr>';
 }

Link to comment
Share on other sites

@@burt Thanks Gary, that gives me almost what Im looking for - it gives the id Number of the referral source rather than the name of the source.

 

How long have you been waiting to quote that one against me ?? :P

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

Not long ;)

 

I don't know the structure of your "referrals" info, so at least you now can see what you need to do. Probably something to do with tep_get_sources_name but why an extra function to get a name is just plain dumb.

Link to comment
Share on other sites

@@burt Yes Im sure it is something to do with this line:

$entry_referral = tep_get_sources_name($source['customers_info_source_id'], $customers['customers_id']);

which takes the customers_info_source_id (ie the source id number) and takes the sources name from the corresponding sources_id from a table called Sources.

 

Hence in the admin/customers.php it is a case of echoing the variable $entry_referral next to the customers name.

 

Been messing with this for a couple of hours now - but as you quite rightly point out - Im no developer :thumbsup:

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

Heather didn't actually mention the file, but I guessed this one.

 

Heather, change:

 

<td class="dataTableContent">' . $customers['customers_info_source_id'] . '</td>

 

to

 

<td class="dataTableContent">' . tep_get_sources_name((int)$customers['customers_info_source_id'], (int)$customers['customers_id']) . '</td>

 

The whole addon looks like it could do with a sorely needed recode.

Link to comment
Share on other sites

@@burt Thanks Gary - works like a dream now.

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...