VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: restodo on April 09, 2014, 07:14:08 AM

Title: Standard Payment Method Percentage problem
Post by: restodo on April 09, 2014, 07:14:08 AM
Hi,

I'm using VM 2.6.0 and I'm trying to configure a Standard Payment Method for Cash On Delivery with 5% of discount.

I can configure right but when I try to buy a product, the discount is incorrect.


For example if I buy a product that cost $ 1000 and I choose Cash On Delivery, total amount should be $ 950 ($ 1000 - $ 50).
But the real thing is that I have a total amount of $ 952,38 (the discount is $ 47,62).

Could someone tell me how can I solve this problem?
It's a simple mathematical equation.


Thanks in advance!
Title: Re: Standard Payment Method Percentage problem
Post by: restodo on April 10, 2014, 04:38:06 AM
I've solved this problem.

This is the solution I've founded. Please developers look because I think it's a bug in VM 2.6.0 code.

I've modified /administrator/components/com_virtuemart/plugins/vmpsplugin.php

At line 997 you have:
         $cartTotalAmount=($cartTotalAmountOrig + $method->cost_per_transaction) / (1 -($method->cost_percent_total * 0.01));

And I've modified with:
         $cartTotalAmount=($cartTotalAmountOrig + $method->cost_per_transaction) * (1 +($method->cost_percent_total * 0.01));

The aritmethical operation of percentage is wrong in the original file.


Greetings from Argentina.