1

how can I get total price of all orders which owned by a single user? I want to assign different type of discounts by finding about total amount of their orders. I'm using

hook_rules_action_info

. should I use commerce_order_load_multiple() ?

2 Answers 2

2

I had a different approach to a similar scenario.

I created a field in the user profile that would store the total amount of orders so far. This field would be increased every time a new order was placed. Also created 3 different roles (silver, gold, platinum) Each role was entitled to different discounts. When the total order would pass the threshold value for the group, the user will be given that role.

1
  • your solution is totally perfect. tanx a lot.
    – nooshinha
    Apr 23, 2013 at 10:10
4

Try this

$orders = commerce_order_load_multiple(array(), array('uid' => $user_id));

You can use the conditions parameter of commerce_order_load_multiple.

1
  • tanx your code works fine. tanx
    – nooshinha
    Apr 23, 2013 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.