With include_tax_in_rrp set to TRUE the RRP price takes into account commerce_tax taxes but not commerce_eu_vat taxes.

This fixes it.

fix_eu_vat.patch900 byteshlykos
Members fund testing for the Drupal project. Drupal Association Learn more


umadesign’s picture

Hi, I've just tested this patch and it seems that the VAT amount being added to the RRP is the VAT calculated AFTER the discount. Being a complete newbie on Drupal Commerce I developed a quick hack that seems to be working, although I'm sure this isn't the right way to do this. The changes are:

>     // save VAT rate
>     foreach ($variables['price']['data']['components'] as $component_key => $component_value) {
>       $component_name = $component_value['name'];
>       if (substr($component_name, 0, 3) == 'vat') {
>         $vat_rate = $component_value['price']['data']['vat_rate_info']['rate'];
>       }
>     }
>       }elseif (substr($component_name, 0, 3) == 'vat') {
>         if (isset($vat_rate)) {
>           $rrp += $rrp * $vat_rate;
>         }

Complete code block:

  if ($variables['options']['include_tax_in_rrp'] == TRUE) {

    // save VAT rate
    foreach ($variables['price']['data']['components'] as $component_key => $component_value) {
      $component_name = $component_value['name'];
      if (substr($component_name, 0, 3) == 'vat') {
        $vat_rate = $component_value['price']['data']['vat_rate_info']['rate'];


    foreach ($variables['components'] as $component_name => $component_value) {
      if (substr($component_name, 0, 3) == 'tax') {
        $rrp += $component_value['price']['amount'];
      }elseif (substr($component_name, 0, 3) == 'vat') {
        if (isset($vat_rate)) {
          $rrp += $rrp * $vat_rate;

Hope this helps somehow

maxollerenshaw’s picture


I applied the above patch to my site and it's worked OK for me. I did get an error saying hunk 2 failed on the patch, after reviewing the code all was correct and my prices are now displaying correctly.

After hacking my code to the same as #1 this has helped.


Aambro’s picture

#1 worked for me so far!

WickedJ’s picture

#1 worked, in dev release
tested 2 but I've had an error and wrong rrp price.

lubwn’s picture

Thanks for a patch. In my case it was counting RRP price badly for some reason, not accurate.

I replaced the line

$rrp += $rrp * $vat_rate;


$rrp += $component_value['price']['amount'];

and now it is counting good again. However I do not really know what I did, was just messing around and somehow it works.

Anyway thanks for a great patch.