News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Invoice randomly shows 0 instead of Payment Name

Started by sscheidegger, May 30, 2022, 17:43:24 PM

Previous topic - Next topic

sscheidegger

Dear VirtueMart dev team,

the invoice sent to our customers usually looks as expected. However, about once a month or less, there is simply a 0 instead of the Payment Method Name. It hapens usually when customers use PayPal.

We tracked down the problem and found the bug in administrator/components/com_virtuemart/plugins/vmpsplugin.php in the getOrderMethodNamebyOrderId() method:


$q = 'SELECT * FROM `' . $this->_tablename . '` '
                        . 'WHERE `virtuemart_order_id` = ' . (int)$virtuemart_order_id;


In our tests, this select statement returns two rows for one OrderId. The first row contains a payment_name and all other information. The second row has most columns including payment_name set to 0, but column paypal_fullresponse contains some information.
As the above select statement contains no ORDER BY clause, the order in which the two rows are returned is not determined. In some cases, the row with payment_name 0 is returned first causing the bug.

Our suggested solution:

$q = 'SELECT * FROM `' . $this->_tablename . '` '
                        . 'WHERE `virtuemart_order_id` = ' . (int)$virtuemart_order_id
                        . ' ORDER BY `id` LIMIT 1';


In a quick test in our environment this resolved the problem.

Thanks a lot, have a great day,
Stefan


Joomla: 3.9.27
VritueMart: 3.8.8 10427
PHP: 8.0.19


Milbo

Nice one, yes I an add that. But there will be a new paypal plugin soon, anyway.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/