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() ?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI 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.
Try this
$orders = commerce_order_load_multiple(array(), array('uid' => $user_id));
You can use the conditions parameter of commerce_order_load_multiple.