My discount_coupons_to_orders table isn't completely empty, but the coupons_id column is, which would explain why the reports can't produce an accurate count.
It also explains the cause of that more serious error I encountered in earlier testing. The system was attempting to enter the values of '' and an orders_id number into discount_coupons_to_orders, but those values were already there.
Here's the code from order_process.php, which I pasted in the correct spot. It looks like the conditional code is being executed, because every time I redeem a coupon, a new entry appears in discount_coupons_to_orders, with the correct order number in the orders_id column, and no data in the coupons_id column.
//kgt - discount coupons
if( tep_session_is_registered( 'coupon' ) && is_object( $order->coupon ) ) {
$sql_data_array = array( 'coupons_id' => $order->coupon->code,
'orders_id' => $insert_id );
tep_db_perform( TABLE_DISCOUNT_COUPONS_TO_ORDERS, $sql_data_array );
}
//end kgt - discount coupons
If it helps you to see this, here are some details of my discount_coupons_to_orders table, according to PhpMyAdmin:
Field Type Null Default
coupons_id varchar(32) No
orders_id int(11) No 0
Indexes:
Keyname: PRIMARY
Type: PRIMARY
Cardinality: 4
Field: coupons_id orders_id