I recently noticed a bug in Virtuemart 2.0.2 that if your website is configured with multiple tax options based on different state/province then Virtuemart checkout page displays and adds all the configured taxes in product sale price, until and unless if user gets logged in before moving on to checkout process.

So for example if your Virtuemart is configured to add 10% tax for Toronto, 20% for Alberta, 15 % for British Columbia and say if product sales price is $50. Now on checkout page buyer will ask to pay $ 72.5 as a total amount, bifurcating $(50 as sales price + 5(10% Toronto tax) + 10(20% Alberta tax) +7.5(BC 15% tax)).

Now as soon the buyer get logged in and confirm for the check out, all the added tax will get cut off and final tax will get applied on the basis state/province displaying on his/her shipping address.

Virtuemart 2.0 multiple tax issue

Virtuemart 2.0 multiple tax issue

Solution to resolve multiple tax issue

Here we have a trick, so by adding a condition to check that whether user is logged in or not, we can show/hide or add/remove the unwanted taxes.

1.0. Locate the file – \components\com_virtuemart\views\cart\tmpl\default_pricelist.php
and search for the below lines of code

<td colspan="4" align="right"><?php echo $rule['calc_name'] ?> </td>
  <?php if ( VmConfig::get('show_tax')) { ?>
     <td align="right"> </td> 
  <?php } ?>

1.1. Replace the above lines of code with –

<td colspan="4" align="right"><?php echo $rule['calc_name'] ?> </td>
  <?php if ( VmConfig::get('show_tax') && $user->id >0) { ?> 
   { ?>
     <td align="right"> </td> 
   <?php } ?>

2.0. Search for the below lines of code -

<td colspan="4"  align="right"><?php echo JText::_('COM_VIRTUEMART_CART_TOTAL')  ?>: </td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right">
<?php echo "<span class='priceColor2'>".$this->cart->prices['billTaxAmount']."</span>" ?>
</td>
<?php } ?>

2.1. Replace the above lines of code with –

<td colspan="4"  align="right"><?php echo JText::_('COM_VIRTUEMART_CART_TOTAL')  ?>: </td>
<?php if ( VmConfig::get('show_tax')) { ?>
if($user->id >0) {  ?>
<td align="right">
<?php echo "<span class='priceColor2'>".$this->cart->prices['billTaxAmount']."</span>" ?>
</td>
<?php
} else  { echo "<td align='right'> $0.00</td>"; } }

3.0. Search for the below lines of code -

<tr  class="sectiontableentry<?php $i ?>">
<td colspan="4" align="right"><?php echo $rule['calc_name'] ?> </td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right"> </td>
<?php } ?>
<td align="right"> <?php echo $this->cart->prices[$rule['virtuemart_calc_id'].'Diff'];  ?></td>
<td align="right"><?php echo $this->cart->prices[$rule['virtuemart_calc_id'].'Diff'];   ?> </td>
</tr>
<?php
if($i) $i=1; else $i=0;
} ?>
<?php

3.1. Place the above code under a conditional tag or simply replace the above lines of code with –

if($user->id  >0){ ?>
<tr class="sectiontableentry<?php $i ?>">
<td colspan="4" align="right"><?php echo $rule['calc_name'] ?> </td>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right"> </td>
<?php } ?>
<td align="right"> <?php echo $this->cart->prices[$rule['virtuemart_calc_id'].'Diff'];  ?></td>
<td align="right"><?php echo $this->cart->prices[$rule['virtuemart_calc_id'].'Diff'];   ?> </td>
</tr>
<?php
if($i) $i=1; else $i=0;
}
}

4.0. Search for the below lines of code –

<td  align="right"><strong><?php echo  $this->cart->prices['billTotal'] ?></strong></td>

4.1. Replace the above lines of code with –

<td  align="right"><strong>
<?php  if($user->id >0)
{
echo $this->cart->prices['billTotal'] ;
}
else
{
echo $this->cart->prices['salesPrice'];
}
?></strong> </td>

Heeee we are done, its time to check the output.

Related posts:

avatar

Author: 


  • lali

    Hi can you provide this solution for VM 2.0.6 as the coding you are asking to replace are deferent in 2.0.6

    • http://www.tips4developer.com Amit

      Hi Lali

      This issue has already been resolved in VM 2.0.6, So while adding taxes you just have to select “Default” under “Shopper Groups:”

  • lali

    Hi Amit,

    I appreciate your feedback. But i read in many forums that people are still having this issue in VM 2.0.6 and i am one of them. I Could show you issue on my site if you are kind enough to help out.

    Thanks.

    • http://www.tips4developer.com Amit

      Hi Lali

      I know that so many peoples asks for the solution on VM 2.0.6 on different forums. And most of them resolved just by following a simple step – [select “Default” under “Shopper Groups:” while adding a new tax].

      So by doing this VM automatically recognized the logged in and anonymous user.

      I hope this helps you. Or you can simply share your site credentials with me on tips4developer@gmail.com, so that i can personalty look in to the issue.