Adrian
Adrian

Reputation: 2656

Order totals including tax in order totals [OpenCart]

I have prices in my store including 20% TAX. The problem is with order totals, let me explain.

Default view in OpenCart (shipping cost is 3€ incl. TAX):

Product X ........................1,50 EUR
------------------------------------------
Shipping  ........................2,50 EUR

Subtotal without tax..............1,25 EUR
TAX 20%...........................0,75 EUR
Total (incl Tax)..................4,50 EUR

The problem is:

Expected result:

Product X ........................1,50 EUR
------------------------------------------
Shipping  ...........................3 EUR

Subtotal without tax..............3,75 EUR
TAX 20%...........................0,75 EUR
Total (incl Tax)..................4,50 EUR

Is there any way to display order totals as I showed?

Upvotes: 6

Views: 2780

Answers (2)

Albert Peschar
Albert Peschar

Reputation: 561

Those using OpenCart 2.x might install this vQmod.

It applies tax-inclusive prices for the subtotal, the shipping costs, and the shipping costs applied by the Automatic Shipping module, if installed.

For information about using vQmod, see instructions on installing vQmod.

Upvotes: 0

You Old Fool
You Old Fool

Reputation: 22969

Not sure why this super old question hasn't been answered but in case anyone still cares, here you go (for Opencart v1.5 but you could easily adapt these concepts for newer versions)...

In order to preserve the actual cost calcs I'm only going to be manipulating the displayed amount for each total. The underlying value will stay as is, which will save us from needing to make any adjustment to the calculations and possibly affecting other parts of the totals in an undesired way.

To show shipping with tax, in catalog/model/total/shipping, change:

'text' => $this->currency->format($this->session->data['shipping_method']['cost']),

to

'text' => $this->currency->format($this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], $this->config->get('config_tax'))),

We're just using the tax class to add the shipping tax into the displayed total based on your "Display Prices With Tax" setting.

Please note, the shipping estimator and shipping charge options in checkout will not be affected by the above changes and will still be displayed without tax as usual - only once you have selected a shipping method and you are looking at the total in the totals section of your cart summary will it be affected. If you want to change the shipping charges to include tax in the estimator and during checkout process there would be other files involved.

Now to include the untaxed shipping total in the displayed subtotal you can edit catalog/model/total/sub_total.php and change:

'text' => $this->currency->format($sub_total),

to

'text' => $this->currency->format($sub_total + (isset($this->session->data['shipping_method']['cost']) ? $this->session->data['shipping_method']['cost'] : 0)),

Upvotes: 1

Related Questions