Virtuemart Coupon Tax Error in Initial Basket

Introduction

In Virtuemart, there is a tax error on the initial basket page after entering a coupon. In a fresh installation of Virtuemart (in this case 1.1.5), I enter a product as below


Then I add a coupon that gives me 80% off.


As you can see, the tax total is the same, which only confuses the user. If you click to checkout, this error fixes itself, but from a customer point of view it is confusing and incorrect.

The Solution

The solution is actually very simple, so simple that I almost missed it. There is a variable scoping problem within the code. A parent file calls a class file. Within the class file, a global variable ($vars) is edited and passed back to the parent file which is then used to calculate the tax. The problem is the edit within the class is not saved. This happens because the variable is not defined as a global variable in the parent file. To fix this:

In www/administrator/components/com_virtuemart/html/basket.php
On or around line 28 is this
<?php
mm_showMyFileName
__FILE__ );
?>

Right after that declaration, add the following code to make $vars global
<?php
mm_showMyFileName
__FILE__ );
global 
$vars;
?>

You are done. Now your initial basket should contain the correct thax.


Comments (5)

  1. Default avatar
    john71 14 years ago 14 years ago
    Great, my problem is solved!
    Good job, thank you, John
    www.gezondehuidwinkel.nl
  2. Default avatar
    ( Guest ) 14 years ago 14 years ago
    Use of coupon shows incorrect price until very end of checkout

    I bought the awo pro, i made a coupon for my site but now all my coupons, even the originals from the standard virtuemart coupon area are broke. I made a coupon for 40% off all products. But during checkout it calculates the prices as 80% off. very confusing to customers. at the final checkout the price shows right but all the steps leading up to it are wrong. What could this be????

    Thanks
    • Your avatar
      seyi 14 years ago 14 years ago
      Please take a look at this thread:
      https://awodev.com/forum/awocoupon-virtuemart/help-section/coupon-does-not-work-correclty
  3. Default avatar
    ( Guest ) 13 years ago 13 years ago
    This does not seem to fix the error in VM 1.1.7? Same tax is being calculated on the retail cost and ignores the discount.

    There are a set of variables listed as:

    [code]
    global $weight_total, $total, $tax_total, $order_tax_details, $discount_factor, $order_total;
    [/code]

    Perhaps your variable for AWO needs to be added here? Please advise.
  4. Default avatar
    ( Guest ) 13 years ago 13 years ago
    RESOLVED TAX ERROR:

    I researched further and found a solution on your forum. I CHECKED-OFF subtract payment discount before tax in the VM configuration and that did the trick.

    Thanks for the support.