Closed scottcwilson closed 3 years ago
No (float)
casts needed, I'm thinking to check for empty()
and set the value to 0 if so.
Could you fill in a couple of blanks so that I can reproduce the issue? When you say that the tax is "not set", specifically how is that value 'not set'?
The value was ''. So empty() is a good check.
Was that an entered value? I can see from the log that the value was an empty string, but I'm trying to determine where that value came from.
I only have the logfile.
How about posting (with admin obfuscation) the entire log file?
(Found it!)
[22-Mar-2021 11:02:13 America/New_York] Request URI: /mysite/admin/index.php?cmd=edit_orders&oID=36423&action=update_order, IP address: xx.xx.xx.xx
--> PHP Fatal error: 1366:Incorrect decimal value: '' for column myaccount_live
.orders_products
.products_tax
at row 1 :: INSERT INTO orders_products (orders_id, products_id, products_model, products_name, products_price, final_price, onetime_charges, products_tax, products_quantity, products_priced_by_attribute, product_is_free, products_discount_type, products_discount_type_from, products_prid) VALUES ('36423', '7722', 'IBM_WAL1219-Paid', 'Product Name', '5.9900', '0', '0', '', '7', '0', '0', '0', '0', '7722') ==> (as called by) /home/myaccount/public_html/mysite/includes/functions/database.php on line 44 <== in /home/myaccount/public_html/mysite/includes/classes/db/mysql/query_factory.php on line 170.
I'm unable to reproduce this on EO 4.6.0-beta, zc157c, PHP 7.3.
I've tried setting a product's tax field to an empty string on the main page, but the processing sets a 0-value tax rate with no issue.
I'll keep this open, just in case you can find the underlying reason for the empty-string product tax.
Does the site, by any chance, have an EO observer that's in effect?
Does the site, by any chance, have an EO observer that's in effect?
No. I wonder if it's related to DB_MODE: STRICT_TRANS_TABLES, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION ?
At any rate, doing an empty()
on products_tax and final_price in admin/includes/functions/extra_functions/edit_orders_functions.php line 960 seems pretty harmless and will prevent these issues from occurring.
That's the mode I run my localhost sites' MySQL in. I'm not a fan of plunking code to correct an issue that can't be reproduced, since there's no way of knowing what the underlying issue is.
Does the product indicated in the log have a tax-rate assigned?
Yes
I can't explain the sequence that caused this issue, but I'll note that the current release version of EO is 4.5.7.
My bad. I didn't have the database-override set for the admin-side of my localhost account.
To recreate, simply blank-out the tax-rate and submit; error occurs.
... noting that the Product Pricing Method must be set the "As entered" for the issue to surface.
--> PHP Fatal error: 1366:Incorrect decimal value: '' for column
live
.orders_products
.products_tax
at row 1 :: INSERT INTO orders_products (orders_id, products_id, products_model, products_name, products_price, final_price, onetime_charges, products_tax, products_quantity, products_priced_by_attribute, product_is_free, products_discount_type, products_discount_type_from, products_prid) VALUES ('36423', '7722', 'IBM_WAL1219', 'XXXXX', '5.9900', '0', '0', '', '7', '0', '0', '0', '0', '7722') ==> (as called by) includes/functions/database.php on line 446 eo_add_product_to_order() called at [.../admin/edit_orders.php:473]
EO version 4.5.4, Zen Cart 1.5.7, PHP 7.2. Perhaps products_tax in eo_add_product_to_order should be cast to (float) before the insert?