How to add columns in credit view - AwoRewards

The first one will display the friends' usernames. So I've tried alone.I've edited the /components/com_aworewards/views/credit/tmpl/default.php file, I've added 2 lines that I've found in /components/com_aworewards/views/referral/tmpl/default.php file. This one : th class="sectiontableheader">

Ok so now I've a new column named "username" but it's empty.I've certainly something more to do but I can't find. Could you help me please.

The second column that I need must display the date when the sponsors have used the coupon. Do you think it's possible ?

Thanks

seyi

4 years ago

0+0 / -0

Hello,

In order to display the referral, you would have to query for it. The sql for the credit screen can be found inwww/administrator/components/com_aworewards/helpers/estore/hikashop/helper.phpfunction sqlCredit

You would need to left join , something like this

LEFT JOIN #__users u2 ON u2.id=h.referral_id

And add u2.username as r_username in the select, then it should work.

For the second column, the usage of coupons in awocoupon is stored in #__awocoupon_history. So you can query for it there, but remember coupons can generally be used more than once. So if this is the case with the coupons, then you would have to account for it.

Regards

benjamin2

4 years ago

0+0 / -0

Hello,

I'm not able to make it working. I've tried to put your code like this :static function sqlCredit($where,$orderby) { $sql = 'SELECT h.*,u.username,c.coupon_code,r.rule_name,CONCAT(o.order_id," (",o.order_number,")") AS order_number,r.id AS rrule_id,p.amount_paid,u2.username AS r_username FROM #__aworewards h JOIN #__users u ON u.id=h.user_id LEFT JOIN #__aworewards_rule r ON r.id=h.rule_id AND r.estore=h.estore LEFT JOIN #__awocoupon c ON c.id=h.coupon_id AND c.estore=h.estore LEFT JOIN #__hikashop_order o ON o.order_id=h.item_id AND h.rule_type="order" LEFT JOIN #__aworewards_payment p ON p.id=h.payment_id LEFT JOIN #__users u2 ON u2.id=h.referral_id WHERE h.estore="hikashop" '. $where.' '.$orderby; return $sql;I probably don't put your code on the right place.Could you help me please ?

seyi

4 years ago

0+0 / -0

Actually looking at it, that will give you the sponsor's user name if the friend was receiving the discount.

To get the friend, if the sponsor is receiving the discount, and if it is an order, then something like this:

LEFT JOIN #__hikashop_user hu2 ON hu2.user_id=o.order_user_id
LEFT JOIN #__users u2 ON u2.id=hu2.user_cms_id

Regards

benjamin2

4 years ago

0+0 / -0

Hello,

Ok it works perfectly.Thanks.Do you think you can give me the same code with #__awocoupon_history, I want to know when the coupon is used by the sponsor ?regards,

I've found a bug, the order date display 01/01/1970 and when the sponsor use the coupon, it display the right date (I'm not really sure I don't try it on few days).I've a table with 2 columns that displaying dates : one is the referral's order date and the other is when the coupon is used by the sponsor.Maybe a conflict between these 2 columns.

Thanks for your help.

benjamin2

4 years ago

0+0 / -0

I've tried with my demo website and it display the date when the coupon is used in both columns.Could you help me please

seyi

4 years ago

0+0 / -0

Hello,

Yes there are 2 timestamp columns in the sql. Change ",hh.timestamp" to ",hh.timestamp AS coupon_use_date"

Then on the template page for the coupon date column, use $row->coupon_use_date instead of $row->timestamp