Reputation: 3253
im trying to get the cart total from the checkout and once the users confirms the order, to add the total amount as reward points...
for an example lets say if someone purchases goods worth 245$ i want to add the 245 as reward points.. Can someone please let me know the best way to do this?
I noted that in opencart the reward points are saved in oc_customer_reward
but i couldnt find the sql in the order model related to that.
Any help will be appreciated
Upvotes: 1
Views: 567
Reputation: 22941
There are lots of ways you could approach this - the easiest I can think of is in system/library/cart/cart.php (path depends on your version) change:
'reward' => $reward * $cart['quantity'],
to
'reward' => ($price + $option_price) * $cart['quantity'],
This way the rewards are passed to any other functions that rely on the cart data - including third party checkout extensions.
Upvotes: 2
Reputation: 1
You can try the following edit for automatic insertion of points when adding products.
admin/view/template/common/header.tpl find:
</head>
add before:
<script type="text/javascript">
$(document).ready(function(){
var product_reward = $("input[id=product_reward]");
$("input[name^='price'],input[name='name'],input[name^='information_description'],input[name^='category_description']").keyup(function(){
var autoPoints = $("input[name^='price'],input[name='name'],input[name^='information_description'],input[name^='category_description']").val();
autoPoints = autoPoints * 0.05;
product_reward.val(autoPoints);
});
});
</script>
Upvotes: 0