1

Is there a solution of calculating a sum of user's orders in drupal commerce (7.41 core) and display them in views? I tried to create a table in view which couldn't show anything except total number of orders but had not user filter. What should I do in order to combine "user" and "drupal commerce"?

1
  • can't find a proper button.... I upped...
    – drru
    Commented Dec 9, 2015 at 18:05

2 Answers 2

3

You can use the view Commerce Backoffice: User orders.

  1. Clone the display users orders.
  2. IN advanced settings, set use aggregation : YES
  3. remove All fields from the display except order Total
  4. In order total field aggregation settings, set type = SUM, group a column = Amount

That's it.

Alternatively, if you don't use Commerce Backoffice module, you can create a view from scratch if you have no user's orders view (I don't remember which default views are provided with Commerce) :

  1. Create a view of orders
  2. Add a contextual filter Commerce Order:UID
  3. Add a field total and repeat steps above

This should be enough. Remain formatting details...

0

I believe the commerce "Cart" submodule provides this out of the box with the "Shopping Cart" block. Make sure that module is enabled, then visit the views page for that block (/admin/structure/views/view/commerce_cart_block/edit/default) I believe initially they provide the sum in the footer of the view. I changed my view to display the count of the number of products and I got rid of everything else except the view cart and checkout links. I was able to get the count of products by turning on aggregation for the view ( Advanced > Other > Use aggregation:Yes ) and then putting a count on the "(Line items referenced by commerce_line_items)" field and then adding sort with a count "(Line items referenced by commerce_line_items)"

Depending on what you're trying to sum, you make be able to get it via aggregation in Views.

Your Answer

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

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