If this is your first visit, check our documentation. To post, register or login.

Viewing coupon stats

Started by mysh on 20 Dec 2013, 2:43 AM · Views: 1,985

Results 1 to 3 of 3
20 Dec 2013, 2:43 AM
#1
mysh avatar

mysh

New Zenner

Join Date:
Nov 2011
Posts:
54
Plugin Contributions:
0

Post #1 by mysh

I was wondering if there was anywhere coupon uses was stored.

I accidently let a popular coupon expire last week and I just noticed it today. I am kicking myself and I wanted to see how times it was attempted in the past week. Is there anywhere this info is stored that I can view?

26 Dec 2013, 4:21 PM
#2
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,816
Plugin Contributions:
4

Post #2 by lhungil

mysh:

I was wondering if there was anywhere coupon uses was stored.

I accidently let a popular coupon expire last week and I just noticed it today. I am kicking myself and I wanted to see how times it was attempted in the past week. Is there anywhere this info is stored that I can view?
In the Zen Cart admin (1.5.x), under "Gift Certificate/Coupons" -> "Coupon Admin" one can select a coupon by name / code and then click "Report" on the right side of the screen to get an overall report of the coupon's use.

One can also retrieve the number of uses by running a SQL Query against the database if needed. In the following examples make sure to add your database "prefix" to table names if you configured a database "prefix". Also replace "your_coupon_code" with the code of the actual coupon you are looking for statistics upon. If one needs to filter by date, that can also be done by altering the example SQL queries to check against the redeem date or order data.

If the coupon was not manually deleted:

SELECT COUNT( `crt`.`unique_id` ) AS `uses`
FROM `coupons` AS `c`
LEFT JOIN `coupon_redeem_track` AS `crt` ON `c`.`coupon_id` = `crt`.`coupon_id`
WHERE `c`.`coupon_code` = 'your_coupon_code'

Alternatively by scanning the order_total table:

SELECT COUNT( `orders_id` ) AS `uses`
FROM `orders_total`
WHERE `class` = 'ot_coupon'
AND `title` LIKE '%your_coupon_code%'

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

26 Dec 2013, 4:30 PM
#3
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,816
Plugin Contributions:
4

Post #3 by lhungil

To check against the dates (using coupon_redeem_track), just add something like:

SELECT COUNT( `crt`.`unique_id` ) AS `uses`
FROM `coupons` AS `c`
LEFT JOIN `coupon_redeem_track` AS `crt` ON `c`.`coupon_id` = `crt`.`coupon_id`
WHERE `c`.`coupon_code` = 'your_coupon_code' AND `crt`.`redeem_date` >= '2013-12-18'

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker