Jump to content
Sign in to follow this  
FWR Media

SalesTracker

Recommended Posts

SalesTracker

 

This is something that I made for myself because I needed to see sales on a daily/period basis and didn't find "customers orders" did it for me.

 

I have been using a version of this for some years and it tends to be the first place I look when I log into admin so I thought it was worth packaging for the community.

 

What does it do?

 

Shows all sales today or sales between a certain date range. It also shows where customers are coming from and if you run PPC campaigns like Adwords it can show you which PPC the customer came from and the specific ad they clicked on.

 

 

Value of sales for the period

orderid (click to go to order)

Customer name (click to go to detail)

Payment Type (e.g. Protx Direct)

Date purchased

Status (Click to change status in order screen)

Referer (Where did the customer come from)

Campaign (which ad campaign/specific ad)

Total value of sale.

 

PLEASE NOTE:

This contribution is designed to be used on a shop with the supertracker contribution installed. Salestracker gets its info re: referer and PPC from the database entries created by the supertracker contribution.

 

 

If it is not installed you will not get the referer/ads functionality. Also I have not tested without supertracker.

 

If I get enough requests I may package it to create its own DB entries independent of Supertracker.

 

Hope you enjoy it

Share this post


Link to post
Share on other sites

I've just installed SalesTracker and find that the info box atop the list of sales doesn't present an accurate total dollar value of the sales.

 

For example,

 

Total Sales = $2345 for the period 17 June, 2007 to 17 August, 2007

Total number of orders = 6

 

In this case the total sales should well exceed the amount shown.

 

Anthony

Share this post


Link to post
Share on other sites
I've just installed SalesTracker and find that the info box atop the list of sales doesn't present an accurate total dollar value of the sales.

 

For example,

 

Total Sales = $2345 for the period 17 June, 2007 to 17 August, 2007

Total number of orders = 6

 

In this case the total sales should well exceed the amount shown.

 

Anthony

 

 

I'll have a look, what should the correct total have been? how many orders?

Share this post


Link to post
Share on other sites
I'll have a look, what should the correct total have been? how many orders?

 

 

Are you saying that it is showing all the orders between the two dates but the total at the top is not agreeing with the orders shown?

Share this post


Link to post
Share on other sites

Found one little error that means that the total is not formatted to 2 decimal places.

 

Find

 

$total_sales = $total_sales + number_format($orders_array['value']);

 

Change to ..

 

$total_sales = $total_sales + number_format($orders_array['value'], 2);

 

This doesn't answer the above which I can't seem to replicate atm.

Share this post


Link to post
Share on other sites

Analli

 

Please run the following query in phpmyadmin and report the results . .

 

SELECT o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.date_purchased, o.orders_status, ot.value
FROM orders as o
LEFT JOIN orders_total as ot
ON o.orders_id = ot.orders_id
WHERE date_purchased between '2007-06-17'
AND '2007-08-17 23:59:59'
AND ot.class = 'ot_total'
ORDER BY orders_id DESC

Share this post


Link to post
Share on other sites

I fixed the decimal problem but here is my output for June 1 to June 30.

 

Total Sales = $285.34 for the period 1 June, 2007 to 30 June, 2007

Total number of orders = 16

 

Order Name Payment Purchased Status Referer Campaign Total

51 Sam T Visa / MasterCard (Secure) 28 June, 2007 Shipped $511.85

50 Joe F Visa / MasterCard (Secure) 26 June, 2007 Shipped $204.63

49 Bob K Payment on Local Pickup. We acce 25 June, 2007 Shipped $204.62

48 Tom B Payment on Local Pickup. We acce 25 June, 2007 Shipped $193.80

47 John S Payment on Local Pickup. We acce 25 June, 2007 Shipped $193.23

46 Rick S Payment on Local Pickup. We acce 25 June, 2007 Shipped $62.58

45 Bill B Payment on Local Pickup. We acce 25 June, 2007 Shipped $190.27

44 Chad S Payment on Local Pickup. We acce 25 June, 2007 Shipped $193.80

43 Barry S Payment on Local Pickup. We acce 25 June, 2007 Shipped $204.60

42 Jen R Payment on Local Pickup. We acce 25 June, 2007 Shipped $204.63

40 John B Visa / MasterCard (Secure) 25 June, 2007 Shipped $62.37

39 Andy M Visa / MasterCard (Secure) 24 June, 2007 Shipped $0.00

38 Norm D Visa / MasterCard (Secure) 22 June, 2007 Shipped $204.63

37 Steve E Visa / MasterCard (Secure) 20 June, 2007 Shipped $64.08

36 Paul O Visa / MasterCard (Secure) 19 June, 2007 Shipped $68.75

31 Terry S Visa / MasterCard (Secure) 1 June, 2007 Shipped $25.63

 

 

You see that the total up top does not match the sales totals.

 

Anthony

Share this post


Link to post
Share on other sites
Analli

 

Please run the following query in phpmyadmin and report the results . .

 

SELECT o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.date_purchased, o.orders_status, ot.value
FROM orders as o
LEFT JOIN orders_total as ot
ON o.orders_id = ot.orders_id
WHERE date_purchased between '2007-06-17'
AND '2007-08-17 23:59:59'
AND ot.class = 'ot_total'
ORDER BY orders_id DESC

 

The output is accurate sales entries for the past 30 sales with all amounts reported correctly.

 

Anthony

Share this post


Link to post
Share on other sites

Odd this it should be a simple calc.

 

Try removing all instances of number_format(

Share this post


Link to post
Share on other sites
Odd this it should be a simple calc.

 

Try removing all instances of number_format(

 

Is that to say remove any line containing that string... the entire line?

 

A

Share this post


Link to post
Share on other sites
Is that to say remove any line containing that string... the entire line?

 

A

 

 

No

 

Lets say it is ..

 

number_format($total_sales, 2)

 

just leave

 

$total_sales

 

search for number format and do this to all see if it makes a difference.

Share this post


Link to post
Share on other sites
No

 

Lets say it is ..

 

number_format($total_sales, 2)

 

just leave

 

$total_sales

 

search for number format and do this to all see if it makes a difference.

 

I'm getting various syntax errors mainly relating to remaining or deleted ";" and ")" characters. There seems to be only two places where the string exists. Could you perhaps post line replacements?

 

Anthony

Share this post


Link to post
Share on other sites
I'm getting various syntax errors mainly relating to remaining or deleted ";" and ")" characters. There seems to be only two places where the string exists. Could you perhaps post line replacements?

 

Anthony

 

 

Try just replacing the following (Lines 153 - 162): -

					 $orderslist[$orders_array['orders_id']] = array(
																 'customers_id'   => $orders_array['customers_id'],
																 'customers_name' => $orders_array['customers_name'],
																 'payment_method' => $orders_array['payment_method'],
																 'date_purchased' => date("j F, Y", strtotime($orders_array['date_purchased'])),
																 'orders_status'  => $status[$orders_array['orders_status']],
																 'referrer'	   => '',
																 'landing_page'   => '',
																 'cart_total'	 => $mycurrency . number_format($orders_array['value'], 2));
				 $total_sales = ($total_sales + $orders_array['value']);

Share this post


Link to post
Share on other sites

That did fix the problem! One small side effect is that the total now comes out NOT rounded to two decimal places. i.e. $2334.4588.

 

Between the two issues, I can live with this one.

 

Thanks.

 

Anthony

Share this post


Link to post
Share on other sites
That did fix the problem! One small side effect is that the total now comes out NOT rounded to two decimal places. i.e. $2334.4588.

 

Between the two issues, I can live with this one.

 

Thanks.

 

Anthony

 

 

Change to this line

 

' . SALESTRACKER_TOTAL_SALES . '<font color="#000055"><b>' . $mycurrency . number_format($total_sales, 2) . '</b></font>' . SALESTRACKER_FOR_PERIOD . date("j F, Y", strtotime($startdate)) . SALESTRACKER_TO2 . date("j F, Y", strtotime($enddate)) . '<br />

Share this post


Link to post
Share on other sites
Change to this line

 

' . SALESTRACKER_TOTAL_SALES . '<font color="#000055"><b>' . $mycurrency . number_format($total_sales, 2) . '</b></font>' . SALESTRACKER_FOR_PERIOD . date("j F, Y", strtotime($startdate)) . SALESTRACKER_TO2 . date("j F, Y", strtotime($enddate)) . '<br />

 

Sorry mate. Exactly change WHAT to that line?

 

Anthony

Share this post


Link to post
Share on other sites

The line starting with

 

' . SALESTRACKER_TOTAL_SALES . '

Share this post


Link to post
Share on other sites

v1.0.1 uploaded to contributions

 

This is a minor change of catalog/admin/salestracker.php changing the formatting of "total sales" in line with the above posts.

 

Thanks to analli for pointing it out.

Share this post


Link to post
Share on other sites

Another improvement.

 

Improved method of finding the referer which removes the necessity for you to manually create a referer array.

 

admin/salestracker.php

 

Remove

 

// List of referers (This could get quite long)
// These are used by seeing if they exist in the $_SERVER['HTTP_REFERER'] predefined variable
$referer_names = array(
				   'google',
				   'msn',
				   'yahoo',
				   'search.live',
				   'ebay',
				   'tiscali',
				 /*'this search engine', // Add as many more as you wish here
				   'that search engine', // Add as many more as you wish here */
				   'aol');

 

Find

 

					  $referernotfound = true;
				  foreach($referer_names as $key) {
					if (strstr($orderslist[$tracker_array['order_id']]['referrer'], $key)) {
					$orderslist[$tracker_array['order_id']]['referrer'] = $key;
					$referernotfound = false;
					}
				  }
				  if ($referernotfound) $orderslist[$tracker_array['order_id']]['referrer'] = SALESTRACKER_UNKNOWN;

 

Replace with

 

					  // Find the refering site
				  if ($orderslist[$tracker_array['order_id']]['referrer'] != '') {
				  $referer_strip = array('http://', 'https://', 'www.');
				  $referer = str_replace($referer_strip, '', $orderslist[$tracker_array['order_id']]['referrer']);
				  $orderslist[$tracker_array['order_id']]['referrer'] = str_replace(strstr($referer, '/'), '', $referer);
				  } else $orderslist[$tracker_array['order_id']]['referrer'] = SALESTRACKER_UNKNOWN;

 

This alteration has not been added to the current contribution but will be added in the next version.

Share this post


Link to post
Share on other sites
The line starting with

 

' . SALESTRACKER_TOTAL_SALES . '

 

 

Parse error: syntax error, unexpected T_STRING in /home/scidac/public_html/catalog/admin/salestracker.php on line 164

Share this post


Link to post
Share on other sites
Parse error: syntax error, unexpected T_STRING in /home/scidac/public_html/catalog/admin/salestracker.php on line 164

 

 

You made a mistake replacing the code.

 

Replace the whole <td></td> with the below: -

 

						 <td colspan="8" style="padding: 5px; color: #818181; border: 1px solid #818181;">
					 ' . SALESTRACKER_TOTAL_SALES . '<font color="#000055"><b>' . $mycurrency . number_format($total_sales, 2) . '</b></font>' . SALESTRACKER_FOR_PERIOD . date("j F, Y", strtotime($startdate)) . SALESTRACKER_TO2 . date("j F, Y", strtotime($enddate)) . '<br />
					 ' . SALESTRACKER_ORDERNUM . $numorders . '<p />
					 </td>

Share this post


Link to post
Share on other sites
You made a mistake replacing the code.

 

Replace the whole <td></td> with the below: -

 

						 <td colspan="8" style="padding: 5px; color: #818181; border: 1px solid #818181;">
					 ' . SALESTRACKER_TOTAL_SALES . '<font color="#000055"><b>' . $mycurrency . number_format($total_sales, 2) . '</b></font>' . SALESTRACKER_FOR_PERIOD . date("j F, Y", strtotime($startdate)) . SALESTRACKER_TO2 . date("j F, Y", strtotime($enddate)) . '<br />
					 ' . SALESTRACKER_ORDERNUM . $numorders . '<p />
					 </td>

 

Works perfectly! Thanks!

 

Anthony

Share this post


Link to post
Share on other sites
Hello,

 

I have a problem with this contribution, I want to referrer my sales who come from www.clubic.com.

The url referrer is http://www.achetezfacile.com/gomag_ph2.php.

 

It is possible to use this contribution with this referrer?

If yes, how I have to process!,

 

Many thanks

 

 

The latest version 1.0.2 will show any referrer regardless of the URL.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×