Forums / Managing Customers and Orders / Customers Referral Report enhancement - Here's mine

Customers Referral Report enhancement - Here's mine

Locked

Views: 2,826

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
12 Jun 2007, 10:45 PM
#1
185p avatar

185p

New Zenner

Join Date:
Dec 2005
Location:
Littleton, CO
Posts:
26
Plugin Contributions:
0

Customers Referral Report enhancement - Here's mine

I have a new customer who needs to pay commissions based on referrals each month, and rather than make him sit down with a calculator, I added totals to the Customers Referral Report.

(HOW to get referrals working based on Discount Coupons is not what I discuss here. There are already a million threads on this.)

WARNING: I am NOT a PHP programmer, so this is quick, sloppy, and dirty!

I hope others find this useful.

Backup then edit admin/stats_customers_referrals.php

Find this:

<?php
    for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
      echo '              <tr>' . "\n" .
           '                <td align="left" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" .
           '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $order->totals[$i]['text'] . '</td>' . "\n" .
           '              </tr>' . "\n";
    }

And add these lines before the final }:

    if ($order->totals[$i]['title'] == 'Sub-Total:') {
          $referral_subtotals += str_replace('$', '', $order->totals[$i]['text']);
          }

    if (eregi("Discount Coupon:*", $order->totals[$i]['title'])) {
          $referral_discounts += str_replace('$', '', $order->totals[$i]['text']);
          }

So now you have:

<?php
    for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
      echo '              <tr>' . "\n" .
           '                <td align="left" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" .
           '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $order->totals[$i]['text'] . '</td>' . "\n" .
           '              </tr>' . "\n";

    if ($order->totals[$i]['title'] == 'Sub-Total:') {
          $referral_subtotals += str_replace('$', '', $order->totals[$i]['text']);
          }

    if (eregi("Discount Coupon:*", $order->totals[$i]['title'])) {
          $referral_discounts += str_replace('$', '', $order->totals[$i]['text']);
          }

    }

So those are the computations. Now, to print the results.... Directly after:

<?php
    $customers_orders->MoveNext();
  }
?>

Add:

<?php
echo '<tr><td></td></tr> <tr><td></td></tr>' . "\n";
echo '<tr><td>Referral Subtotals: ' . $referral_subtotals . '</td></tr>' . "\n";
echo '<tr><td>Referral Discounts: ' . $referral_discounts . '</td></tr>' . "\n";
$referral_total = $referral_subtotals + $referral_discounts;
echo '<tr><td>Referral Subtotals minus Discounts: $' . $referral_total . '</td></tr>' . "\n";
?>

So now you have:

<?php
    $customers_orders->MoveNext();
  }
?>

<?php
echo '<tr><td></td></tr> <tr><td></td></tr>' . "\n";
echo '<tr><td>Referral Subtotals: ' . $referral_subtotals . '</td></tr>' . "\n";
echo '<tr><td>Referral Discounts: ' . $referral_discounts . '</td></tr>' . "\n";
$referral_total = $referral_subtotals + $referral_discounts;
echo '<tr><td>Referral Subtotals minus Discounts: $' . $referral_total . '</td></tr>' . "\n";
?>
25 Jan 2008, 4:49 PM
#2
rwhaley avatar

rwhaley

New Zenner

Join Date:
Oct 2004
Location:
Plainfield, IL
Posts:
6
Plugin Contributions:
0

Re: Customers Referral Report enhancement - Here's mine

Works great.... thanks!

I would like a little more... I'm not a programmer though. Any thoughts on how to get that report to spit out the following after selecting a date range for all referral codes?

Referral Code:

Order Data Order Number Customer Name Order Total
(details) (details) (details) (details)

Totals Sum
Donation: Sum * .10

Next Referral Code:

Order Data Order Number Customer Name Order Total
(details) (details) (details) (details)

Totals Sum
Donation: Sum * .10

Ray Whaley
compdetail
[email protected]

24 Feb 2008, 2:08 AM
#3
pixeldiva avatar

pixeldiva

New Zenner

Join Date:
Feb 2008
Posts:
7
Plugin Contributions:
0

Re: Customers Referral Report enhancement - Here's mine

that's great. Is it possible to have this report downloaded as a csv file (similar to the export order history mod? I tried copying some of the code and the report does download but when I open it in Excel I have also the navigation included. How do I get rid of that and just show the rows of data? Any help is much appreciated. Zencart is a great shopping cart, I'm just not a programmer. :sad:

16 Mar 2008, 4:34 PM
#4
ralyn avatar

ralyn

New Zenner

Join Date:
Sep 2006
Location:
New Boston, IL
Posts:
57
Plugin Contributions:
0

Re: Customers Referral Report enhancement - Here's mine

I have not tried your modification yet, but plan to test it soon. This looks like a step in the right direction for what I'm looking for. I'm needing a much better report for paying Consultant commissions than what zen has in it. Is there a way for the referer to see their referral records from their customer account area, that you're aware of?

Ralyn Speerly Schraceo
Under The Rainbow
http://www.undertherainbow.us

1 Jun 2009, 4:44 PM
#5
tmr21 avatar

tmr21

New Zenner

Join Date:
Apr 2007
Posts:
3
Plugin Contributions:
0

Re: Customers Referral Report enhancement - Here's mine

Great job on this module, it worked like a charm! Thank you! :smile: