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"?
You can use the view Commerce Backoffice: User orders.
- Clone the display users orders.
- IN advanced settings, set use aggregation : YES
- remove All fields from the display except order Total
- In order total field aggregation settings, set type = SUM, group a column = Amount
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) :
- Create a view of orders
- Add a contextual filter Commerce Order:UID
- Add a field total and repeat steps above
This should be enough. Remain formatting details...
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.