News:

Looking for documentation? Take a look on our wiki

Main Menu

[SOLVED] Bug in Standard payment methods

Started by henry_osn, September 27, 2021, 17:11:01 PM

Previous topic - Next topic

henry_osn

The tax / tributes does not work on current version, VirtueMart 3.8.8 10472. How to fix for "standard payment"? Thanks

Still about https://forum.virtuemart.net/index.php?topic=117823.30


Milbo

#2
Come on, it works for soo many people. Do you really think we have a glasbowl?

Please describe your error. Tell your configuration and your desired result. Make nice screenshots, cut the important parts and upload it here. This way no one know what you mean.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

henry_osn

Sorry, but it seemed pretty clear to me. I even quoted the post of an old discussion, where the problem had been solved, but in the latest version of Virtuemart, it doesn't work. There are no errors, it just the tax / tributes for "standard payment" does not work in cart. I type a fee in the payment method (-8% for example) and nothing happens in the cart. Thanks again.

Milbo

If you would post your settings! So you used -8%,.... For which setting?

Fee per transaction ? or

Fee or cashback in percent of the total amount.

Did you read the tooltips?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

henry_osn

Thanks for reply.

Fee per transaction -> -8%

I tried also "tax", but not work.

Nothing happens in the cart.

jjk

I don't have a version 3.8.8 10472 installed, but in my 3.8.9 10473 any fees I add to a standard payment method does show up in the cart right next to the standard payment method.

Do you use the original VirtueMart checkout or a third party checkout?

Note: In the 'Fee per transaction' form field an extra fee would be a positive fixed amount. A negative number would be a rebate.
Maybe you can supply screenshots of your setting and your cart view with the customer data cut off.

Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

henry_osn

Thank you all. I was able to offer the percentage discount using the "Fee or cashback in percent of the total amount" field.

But the calculation doesn't work well. I offer 10% off (I typed -10, no %), but the calculation is always wrong. For example for a $1.00 product the 10% discount is equal to $0.09 and not $0.10.

henry_osn

I found the solution -> https://forum.virtuemart.net/index.php?topic=128671.0

But they still haven't fixed the bug in the current version.

Please read the indicated post.

Important: the payment method in question is the default.

Gomad

Hello

I am using

Distro Name: CentOS Linux release 7.9.2009 (Core)
PHP Version 7.4.24
Joomla! 3.10.2
Virtuemart 3.8.8 10472

I also found errors in the Virtuemart default payment method

If I do set a value in the field "Fee or cashback in percent of the total amount." the fee or rebate are calculated, but the result is wrong.

I did input just numbers without  % sign

In order to try to understand what happens I tried with a simple case, 10% commission fee, creating a cart with products for 1000 € net (not taxes, no shipping fees, just 1000€ net) the result of the percentage fee calculator is 111,11 € and outputs a total of 1111,11€

What is causing to transform the 10% I setup into the 11,111% that is effectively calculated?

I read the other old post linked by Henry >>> "I found the solution -> https://forum.virtuemart.net/index.php?topic=128671.0".

Sincerely I did not understand well the logics used as I lack a lot of info on the whole rest, anyhow, I found a way to have it working apparently, but setting it up in this way I ask myself what might happen in other possible cases...

Watching at that old post seems in virtuemart 3.8.8 that in the administrator/components/com_virtuemart/plugins/vmpsplugin.php file at line 1237 the string used in the "simple case" seems to belong to the "progressive case" and vice versa.

I tried to swap the lines, and seems to work.

so the original code is this one:

         if(!$progressive){
//Simple
$cartTotalAmount=($cartTotalAmountOrig + $method->cost_per_transaction) * (1 +($method->cost_percent_total * 0.01));
//vmdebug('Simple $cartTotalAmount = ('.$cartTotalAmountOrig.' + '.$method->cost_per_transaction.') * (1 + ('.$method->cost_percent_total.' * 0.01)) = '.$cartTotalAmount );
//vmdebug('Simple $cartTotalAmount = '.($cartTotalAmountOrig + $method->cost_per_transaction).' * '. (1 + $method->cost_percent_total * 0.01) .' = '.$cartTotalAmount );
} else {
//progressive
$cartTotalAmount = ($cartTotalAmountOrig + $method->cost_per_transaction) / (1 -($method->cost_percent_total * 0.01));
//vmdebug('Progressive $cartTotalAmount = ('.$cartTotalAmountOrig.' + '.$method->cost_per_transaction.') / (1 - ('.$method->cost_percent_total.' * 0.01)) = '.$cartTotalAmount );
//vmdebug('Progressive $cartTotalAmount = '.($cartTotalAmountOrig + $method->cost_per_transaction) .' / '. (1 - $method->cost_percent_total * 0.01) .' = '.$cartTotalAmount );


I changed it into this:

                                if(!$progressive){
//Simple
$cartTotalAmount=($cartTotalAmountOrig + $method->cost_per_transaction) / (1 -($method->cost_percent_total * 0.01));
//vmdebug('Simple $cartTotalAmount = ('.$cartTotalAmountOrig.' + '.$method->cost_per_transaction.') * (1 + ('.$method->cost_percent_total.' * 0.01)) = '.$cartTotalAmount );
//vmdebug('Simple $cartTotalAmount = '.($cartTotalAmountOrig + $method->cost_per_transaction).' * '. (1 + $method->cost_percent_total * 0.01) .' = '.$cartTotalAmount );
} else {
//progressive
                                $cartTotalAmount=($cartTotalAmountOrig + $method->cost_per_transaction) * (1 +($method->cost_percent_total * 0.01));
//$cartTotalAmount = ($cartTotalAmountOrig + $method->cost_per_transaction) / (1 -($method->cost_percent_total * 0.01));
//vmdebug('Progressive $cartTotalAmount = ('.$cartTotalAmountOrig.' + '.$method->cost_per_transaction.') / (1 - ('.$method->cost_percent_total.' * 0.01)) = '.$cartTotalAmount );
//vmdebug('Progressive $cartTotalAmount = '.($cartTotalAmountOrig + $method->cost_per_transaction) .' / '. (1 - $method->cost_percent_total * 0.01) .' = '.$cartTotalAmount );
}



Apparently works now, however I'd like to know if this is correct and why this happens...

In that old post I read this message from Milbo that seems relevant

" Mosdata, please read closely again
Quote from: Milbo on March 10, 2015, 12:34:00 pm

    The payment plugin can implement an option for that
    function setCartPrices (VirtueMartCart $cart, &$cart_prices, $method, $progressive = true) {

    progressive considers that you have to loan the fee itself

Your payment is using the progressive option"


What does mean "progressive"?

What does mean "progressive considers that you have to loan the fee itself"?

Loan the fee? I do not understand this, can anyone please explain it?

I am testing it with the standard Virtuemart payment method, reading that post one might think that there is a way to set a payment method as progressive or not progressive, if it is so, how can I set the standard Virtuemart payment method as "progressive" or "non progressive"?

I did not see an option to do that anywhere (I think at least)...

Can anyone confirm that swapping the position of those two lines is OK and that does not cause other kind of errors in other circumstances?

Is it possible to have more info on all of this?

Does exist some documentation explaining how this work ?

Thank you

Milbo

Yes, the progressive calculation is wrong for cashback. I added an option now, so you can change the behaviour per config option
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Gomad

Hello Milbo

Thank you,  I  guess that it will available with the next Virtuemart release, so, for the moment being, can I leave the code as I corrected it without observing other errors in different cases?

I am thinking to use also stripe when I will have ended the general setup of the website.

In particular, the code in the file administrator/components/com_virtuemart/plugins/vmpsplugin.php I modified, is it going to be used only by the standard default Virtuemart payment method?

Or maybe that same script is also somehow used by third parties payment method plugins? (thus the modification I did could cause malfunctioning in other scripts relying on it?)

Sorry for the naive questions, I am learning from scratch...

Thank you

GJC Web Design

the function setCartPrices is used in numerous bundled payment plugins .. just search them for setCartPrices

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

It works without interfering. Any plugin which calls itself the function and uses the already existing $progressive parameter will work as before.

But all other plugins have now a new core parameter, $progressive, which is automatically added, if they use the lately introduced core parameters (categories, blocking, categories, and so on). If the method provides the parameter $progressive, then it overrides the function parameter, because it was wrong from begin, to add it.

There is only one small problem left. When a plugin must use progressive calculation (actually the normal way!) and uses the core variables. Then users may select the wrong option. Maybe I just introduce a small extra variable, which is set in constructor "forceProgressive", or so.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/