Maybe I'm missing something, but I'm building and testing now and I've made well over 100 test orders at this point, with every single one of my products having rewards points set on them, yet I have never been awarded a single reward point for any purchase.
I can add rewards points just fine through the admin, but on checkout, rewards points are never issued to the customer.
So I searched ....
This is 1.5.1.3 btw.
There are 15 references to the phrase DB_PREFIX . "customer_reward in the entire system which would signify some action with the customer_rewards table where rewards are inserted and calculated for customers.
Those 15 queries with the customer_rewards table break down like so:
SELECT :: 10
DELETE :: 3
UPDATE :: 0
INSERT :: 2
Only updates or inserts could possibly add rows to the table so that leaves only 2 possible places in the script where points could be added to the account.
1. admin/model/sale/customer.php
This is used from within the admin section to add rewards points to a customer and the only way I've found so far to get points in there.
2. catalog/model/total/reward.php
The confirm method within this model searches each entry in the order_total variable passed in by sub-string for any items that contain (), which would ONLY be rewards points entries that are used to PAY FOR a purchase, and then inserts an entry with a negative value ie: points= (float)-$points thus subtractive points that have been used to purchase.
Thats' it ... I've searched through this code several times now and nowhere can I find a place where points are ADDED to a customers account other than manually through the admin panel.
Am I missing something? There doesn't seem to be much reason for points if the customer never receives them.
If someone, Daniel perhaps can address this and let me know what the heck I'm missing I would be greatly appreciative.
Thanks a lot for the great work you guys do.
-Vince
Points can only be added to Real Customers (i.e. not to Guest Checkout Customers)
That has the be the stupidest thing I've ever heard of.
As if people are going to go into the admin panel for each sale and add points. We have over 15,000 orders per month.
I wrote it all into the customer class once the order reaches the proper status, this allows us to give points for other tasks as well such as reviewing and sharing products on Twitter and Facebook.
There's a serious lack of forward thinking here in reference to this issue. Crazy.
Peace.
Did you get it working automatically then mate?
Care to share?
If not i may make a mod for this as this is batsh*t crazy!
Professional UK Based eCommerce - Our Free Opencart Mods - Our Premium Opencart Mods
Kashflow Integration
Professional UK Based eCommerce - Our Free Opencart Mods - Our Premium Opencart Mods
Kashflow Integration
2. Add new public variable to Customer class:
Code: Select all
public $rewardpoints;
Code: Select all
if ($customer_query->num_rows) {
Code: Select all
$this->rewardpoints = $this->getRewardPoints();
Code: Select all
$this->rewardpoints = $this->getRewardPoints();
(you'll see where)
5. Inside: public function logout() SET:
Code: Select all
$this->rewardpoints = '';
(you'll see where)
6. Create new function:
Code: Select all
public function getRewardPoints() {
$query = $this->db->query("SELECT SUM(points) AS total FROM " . DB_PREFIX . "customer_reward WHERE customer_id = '" . (int)$this->customer_id . "'");
$total = ($query->row['total'] > 0) ? $query->row['total'] : 0;
return $total;
}
Code: Select all
public function addRewardPoints($customer_id, $description = '', $points = '', $order_id = 0) {
if ($customer_id) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$customer_id . "', order_id = '" . (int)$order_id . "', points = '" . (int)$points . "', description = '" . $this->db->escape($description) . "', date_added = NOW()");
}
}
Code: Select all
// customer shares their purchase on Facebook from order success page
$this->customer->addRewardPoints (5, "Shared Purchase on Facebook", 10, 2263);
Code: Select all
// customer reviews a product
$this->customer->addRewardPoints (5, "Product Review for" . $product['name'], 5);
Also you can show the customer's current points simply by calling the variable in your controller and rendering it to the view:
Code: Select all
$this->data['reward_points'] = $this->customer->rewardpoints;
Code: Select all
$this->data['reward_points'] = $this->customer->getRewardPoints();
Just keep in mind this is a permanent approach as the customer class is a core file. Make sure you write this stuff down and save it if you're gonna upgrade your OC to a new version.
Enjoy
-V
If i do ill send it you man - if thats OK by you anyway?
Professional UK Based eCommerce - Our Free Opencart Mods - Our Premium Opencart Mods
Kashflow Integration
If we upgrade we do it via changelog. I've completely rewritten a great deal of the front end of this for our own HTML5 fork of the project. It doesn't get any automated updates of any of that stuff.
No vQmods here, only solid error free code
Peace.
Just confirm for me what the above stuff will actually do to my site..
I get that i can go on to reward them for other stuff, but does this add the reward points they acrue from buying stuff to their account automatically?
Thanks man!
Professional UK Based eCommerce - Our Free Opencart Mods - Our Premium Opencart Mods
Kashflow Integration
$this->customer->addRewardPoints (5, "Product Review for" . $product['name'], 5);
It's your job to call $this->customer->addRewardPoints (5, "Product Review for" . $product['name'], 5); in the appropriate place such as order confirmation. It's the same type of call that OC uses to add to cart.
catalog/model/checkout/order.php
Line 211 is where mine is, but your milage may vary, as long as it's after the language file is loaded.
Code: Select all
// Add rewards points
// this should really go earlier in the script
// but needed a language file loaded first
if ($order_info['customer_id'] > 0):
$description = sprintf($language->get('reward_purchase'), $order_info['order_id']);
$this->customer->addRewardPoints ($order_info['customer_id'], $description, $order_info['reward'], $order_info['order_id']);
endif;
Code: Select all
// Rewards points for sale
$_['reward_purchase'] = 'Reward points from Order ID: #%s';
-Vince
how can I display total reward points (for current order) somewhere under
Sub-Total:
or
VAT:
on the "Confirm order" page?
I will use reward points for anothe purpose, and I need it allways displayed.
Thanks.
There's a rewards module now, but it does something different, it's used for displaying the reward points redeemed at checkout. You can see it at:
admin->extensions->order totals
There's a mod there called reward points I think ...
You'd have to do some programming to make this happen, it's not a switch you can turn on and off.
-V
http://www.opencart.com/index.php?route ... on_id=6385
We made it as i fear your changes were just too much!
This is vQmod and works by auto adding them when order status changed to COMPLETE.
Professional UK Based eCommerce - Our Free Opencart Mods - Our Premium Opencart Mods
Kashflow Integration
http://www.opencart.com/index.php?route ... on_id=6486
Users browsing this forum: No registered users and 287 guests