If you want an order field in your view, representing the total price of the order?
Do the following:

Extract the attachment into the same folder as commerce_order_handler_field_order_type.inc

Complement commerce_order.views.inc with

  // Expose the order total price.
  $data['commerce_order']['order_total'] = array(
    'field' => array(
      'title' => t('Order total price'),
      'help' => t('The sum of all line items totals.'),
      'handler' => 'commerce_order_handler_field_order_total',
    ),
  );

And commerce_order.info with

files[] = includes/views/handlers/commerce_order_handler_field_order_total.inc

Comments

rszrama’s picture

Damien and I discussed this last week as well, and it seems likely that we'll end up with an actual Price field on the order that is recalculated when necessary to contain the latest order total. I need to revisit our notes to discuss currency issues...

pieterdc’s picture

The actual order price field (views integration) wouldn't have the option to sum only the items of a certain line item type (which I have - and use - now), I guess ?

But it would be better in lots of other use cases, I know.

rszrama’s picture

Ahh, yeah, it would be nice to maintain a way to subtotal things. Damien and I discussed that, working it into the line item summary area handler somehow... the biggest hangup as usual is multi-currency orders (i.e. how to represent sums in different currencies or combine them into one).

I guess we'll need to maintain some version of this pseudo-field along with a Field API type field on the order.

alexpua’s picture

About different currencies, in store setting owner has to choice base currency for example usd or national..., all orders must be calculate to the base currency and save with exchange rate for that date
In one order customer can not add goods with different currencies.

alexpua’s picture

StatusFileSize
new111.49 KB

Can anybody explain what happen
I try to add Order total views field
and receive next message:

Debug:
'Missing handler: commerce_order order_total field'
in views_get_handler() (line 841 of /var/www/drupal/sites/all/modules/views/views.module).

look attach

After I deleted all the changes - message remained
I rewrite modules Commerce and Views and - message remained

alexpua’s picture

StatusFileSize
new87.43 KB

I do not what happen before, I re-install all and add changes "total" before switch on modules
last message disappear but we have new one
look attach

rszrama’s picture

Title: Order total views field » Add a line item total Views field
Status: Needs review » Needs work

I've actually just added an order total field to orders, so that's covered. I think what this patch likely represents is more of a "line item total" field, so I'm changing the title accordingly.

Here's the commit for the new order total field:

https://github.com/rszrama/drupalcommerce/commit/75dbcce26ac4995f340bfc2...

bojanz’s picture

Do we want to do anything else here? Seems done.

jsacksick’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)