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

Cancelled order status and SQL error

Started by sandomatyas, January 17, 2018, 12:58:53 PM

Previous topic - Next topic

sandomatyas

There are special cases where VM tables are a bit inconsitens because of user or 3rd party software. In my case a simple script modifies the value of #__virtuemart_products.product_sale field. It stores to the product sales of the last 4 weeks. Don't ask, it's a customer's request.
But in special cases if I cancel an order VM wants to set the correct product_sale value wich can lead to an SQL error
This is the SQL error for updateStatusForOneOrder
[query:JDatabaseExceptionExecuting:private] => UPDATE `jos_virtuemart_products` SET `product_in_stock` = `product_in_stock` +10, `product_sales` = `product_sales` -10 WHERE `virtuemart_product_id` = 339
[message:protected] => BIGINT UNSIGNED value is out of range in '(`demo_virtuemart`.`#__virtuemart_products`.`product_sales` - 10)'

This is because the value of product_sales is less than 10.
I can fix it for myself, so it is just a notice if anybody else has the same problem.
I know it isn't because VM but the error occours in VM so maybe a simple check wouldn't hurt.

Studio 42

Add a function  adding the same value in product sales so you never have a negative value.
You can use a simple vmpayment plugin with only 1 function plgVmOnCancelPayment to do this