0

I need the final tax amount for an order found on the commerce order total. when using dpm and entity metadata wrapper i can't seem to break it out in order to grab the value.

$order = entity_metadata_wrapper('commerce_order', 3);
dpm($order->commerce_order_total->getPropertyInfo());
0

the most thorough insight on getting access to the tax line and individual subtotals. found via: https://gist.github.com/BBGuy/3e1f624eaee2088d8eee

// order total object
$order_total_obj = $order_wrapper->commerce_order_total->value();
// Order total (cents).
$order_total = $order_total_obj['amount'];
// order currency code
$currency_code = $order_wrapper->commerce_order_total->currency_code->value();
// subtotal without vat
$total_ex_vat = commerce_price_component_total($order_total , 'base_price');
// total tax (in this case vat 20%)
$total_vat = commerce_price_component_total($order_total , 'tax|vat_20');
// subtotal with vat
$sub_total = $total_ex_vat['amount'] + $total_vat['amount'];
// formatted price string with currency sign
$sub_total = commerce_currency_format($sub_total, $currency_code);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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