If this is your first visit, check our documentation. To post, register or login.
Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / Fatal Error when purchasing Gift Certificate

Fatal Error when purchasing Gift Certificate

Started by mvstudio on 18 Feb 2020, 4:45 PM · Views: 14,801

Results 1 to 20 of 30
18 Feb 2020, 4:45 PM
#1
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Fatal Error when purchasing Gift Certificate

Zen Cart 1.5.6c
One Page Checkout recently updated to version 2.2.0
Latest Square Up version

The problem
Customers complained they see a blank page and/or an error message when trying to purchase Gift Certificates. Error message on screen "Warning: and error occurred...."

After running all the tests I could think of, disabling OPC and using check/money order as a payment method the issue persists. Reverting to the original store template, disabling OPC and paying with check/money order the issue persist, which leads me to believe there is something happening non related to either Square nor OPC.

The only thing that actually worked and I was able to place an order for a gift certificate was by changing the Yes, Skip Shipping Address, to No, Normal Shipping Rules, which treats the item as a regular product. I'm inclined to believe something isn't working when shipping isn't required, but I have no idea where to even begin to check.

Log (private values replaced with XXXXXXXXX):
[18-Feb-2020 11:24:08 America/Detroit] Request URI: /index.php?main_page=checkout_process, IP address: XXXXXXX
#1 trigger_error() called at [/includes/classes/db/mysql/query_factory.php:171]
#2 queryFactory->show_error() called at [/includes/classes/db/mysql/query_factory.php:143]
#3 queryFactory->set_error() called at [/includes/classes/db/mysql/query_factory.php:270]
#4 queryFactory->Execute() called at [/includes/functions/functions_general.php:952]
#5 zen_db_perform() called at [/includes/classes/order.php:695]
#6 order->create() called at [/includes/modules/checkout_process.php:95]
#7 require(/includes/modules/checkout_process.php) called at [/includes/modules/pages/checkout_process/header_php.php:14]
#8 require(/includes/modules/pages/checkout_process/header_php.php) called at [/home/koolwedd/public_html/index.php:36]
--> PHP Fatal error: 1366:Incorrect integer value: '' for column koolwedd_TEMP.orders.delivery_address_format_id at row 1 :: INSERT INTO orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, payment_module_code, shipping_method, shipping_module_code, coupon_code, cc_type, cc_owner, cc_number, cc_expires, date_purchased, orders_status, order_total, order_tax, currency, currency_value, ip_address) VALUES ('1', 'XXXXXXXX', '', 'XXXXXXXX', '', 'XXXXXXX', 'XXXXX', 'XXXXXX', 'United States', '0000000000', 'XXXXXXX', '2', ' ', '', '', '', '', '', '', '', '', 'XXXX', '', 'XXXXXXX', '', 'XXXXXXX', 'XXXX', 'XX', 'United States', '2', 'Check/Money Order', 'moneyorder', 'Free Shipping-', 'free', '', '', '', '', '', now(), '1', '100', '0', 'USD', '1.000000', 'XXXXXXX') ==> (as called by) /includes/functions/functions_general.php on line 952 <== in /includes/classes/db/mysql/query_factory.php on line 171.

Has anyone seen this behavior before? Any clue where the problem could be and how can it be solved?

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 5:32 PM
#2
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,904
Plugin Contributions:
23

Re: Fatal Error when purchasing Gift Certificate

lat9 has released a 2.3.0 version that might address the GC problem.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

18 Feb 2020, 6:26 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Fatal Error when purchasing Gift Certificate

Is your store's /includes/classes/order.php the as-shipped zc156c version? I just tried placing a GC-only order (with and without OPC) and had no issue.

18 Feb 2020, 7:20 PM
#4
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

dbltoe:

lat9 has released a 2.3.0 version that might address the GC problem.

I thought it would be an OPC issue, but when I tested with OPC disabled and just the classic template the behavior was still present. I'll download and install the new version you suggest, but I don't believe OPC is the problem.

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 7:27 PM
#5
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

lat9:

Is your store's /includes/classes/order.php the as-shipped zc156c version? I just tried placing a GC-only order (with and without OPC) and had no issue.

Yes, identical.
With or without OPC I cannot get the purchase of a GC to go through. The only way it goes through is if I change the product from "Yes, Skip Shipping Address" to "No, Shipping Address Required"

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 8:10 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Fatal Error when purchasing Gift Certificate

The underlying issue is that the order-processing, which for some unknown reason is different on your site, has set the delivery_address_format_id field to '' (an empty string) which is an invalid decimal value. That, in conjunction with your webhost having defaulted the MySQL mode to more strict settings is what's leading to that error.

Since you're running zc156c, you can see that MySQL Mode setting at the top of the display rendered by your admin's Tools->Server/Version Info.

You can work-around the issue by creating a .php file containing:

<?php
/**
 * @package install
 * @copyright Copyright 2003-2018 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: Drbyte Sun Jan 7 22:37:45 2018 -0500 Modified in v1.5.6 $
 *
 */

/**
 * Optionally set a MySQL mode during installation
 * Ref: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html
 */
define('DB_MYSQL_MODE', 'TRADITIONAL');
//define('DB_MYSQL_MODE', 'STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO');

... in both the storefront and admin main directories, e.g. [/admin]/includes/extra_datafiles/mysql_mode_control.php.

I'll note, though, that there might be webhosts that disallow that override.

18 Feb 2020, 8:26 PM
#7
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

lat9:

The underlying issue is that the order-processing, which for some unknown reason is different on your site, has set the delivery_address_format_id field to '' (an empty string) which is an invalid decimal value. That, in conjunction with your webhost having defaulted the MySQL mode to more strict settings is what's leading to that error.

Since you're running zc156c, you can see that MySQL Mode setting at the top of the display rendered by your admin's Tools->Server/Version Info.

Thanks Cindy!
I'll implement the fix and report back.

I never had an issue with GC before this version of ZC. This one went completely over my head.
Question, How is the order processing different on my site? Is this something I could have inadvertently caused?
I checked the database and delivery_address_format_id is set to 0 which is what the installation file also has (I keep copies of the files I download). Is it not supposed to be 0? If I modify the default value could that possibly solve the issue? Just trying to learn =)

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 8:41 PM
#8
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

lat9:

The underlying issue is that the order-processing, which for some unknown reason is different on your site, has set the delivery_address_format_id field to '' (an empty string) which is an invalid decimal value. That, in conjunction with your webhost having defaulted the MySQL mode to more strict settings is what's leading to that error.

Since you're running zc156c, you can see that MySQL Mode setting at the top of the display rendered by your admin's Tools->Server/Version Info.

You can work-around the issue by creating a .php file containing:

<?php /** * @package install * @copyright Copyright 2003-2018 Zen Cart Development Team * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: Drbyte Sun Jan 7 22:37:45 2018 -0500 Modified in v1.5.6 $ * */ /** * Optionally set a MySQL mode during installation * Ref: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html */ define('DB_MYSQL_MODE', 'TRADITIONAL'); //define('DB_MYSQL_MODE', 'STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO'); ``` > ... in both the storefront and admin main directories, e.g. \[/admin]/includes/extra_datafiles/mysql_mode_control.php. > > I'll note, though, that there might be webhosts that disallow that override. Unfortunately the patch didn't work :no::cry:

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 8:59 PM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Fatal Error when purchasing Gift Certificate

mvstudio:

Unfortunately the patch didn't work :no::cry:
When you view your admin's Tools->Server/Version Info, what shows in that upper area?

18 Feb 2020, 9:01 PM
#10
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Fatal Error when purchasing Gift Certificate

mvstudio:

Thanks Cindy!
I'll implement the fix and report back.

I never had an issue with GC before this version of ZC. This one went completely over my head.
Question, How is the order processing different on my site? Is this something I could have inadvertently caused?
I checked the database and delivery_address_format_id is set to 0 which is what the installation file also has (I keep copies of the files I download). Is it not supposed to be 0? If I modify the default value could that possibly solve the issue? Just trying to learn =)
The default value should be an integer 0 (as you see in your database). The issue is that not only PHP but also MySQL implementations are getting more strict, so you can no longer store '' (an empty string) and have it be magically converted to a 0 when the database field is set to contain an integer value.

18 Feb 2020, 9:04 PM
#11
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

lat9:

When you view your admin's Tools->Server/Version Info, what shows in that upper area?

What you described before

MySQL Slow Query Log Status: On
MySQL Slow Query Log File: server-slow.log
MySQL Mode: STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, TRADITIONAL, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 9:08 PM
#12
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

lat9:

The default value should be an integer 0 (as you see in your database). The issue is that not only PHP but also MySQL implementations are getting more strict, so you can no longer store '' (an empty string) and have it be magically converted to a 0 when the database field is set to contain an integer value.

Of course it makes sense.
Is it possible to "trick" the system to include a meaningless value in the instance of GC orders? Or perhaps replace the empty values with the customer's own info therefore eliminating the error?
Just trying to figure out a different approach, that's all.

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 9:17 PM
#13
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Fatal Error when purchasing Gift Certificate

mvstudio:

Of course it makes sense.
Is it possible to "trick" the system to include a meaningless value in the instance of GC orders? Or perhaps replace the empty values with the customer's own info therefore eliminating the error?
Just trying to figure out a different approach, that's all.
If you send me a copy of your version of /includes/classes/order.php to my direct email (if you don't have it, PM me), I'll give it a look.

18 Feb 2020, 9:18 PM
#14
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Fatal Error when purchasing Gift Certificate

mvstudio:

What you described before

MySQL Slow Query Log Status: On
MySQL Slow Query Log File: server-slow.log
MySQL Mode: STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, TRADITIONAL, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION
Does that show even after you've added that /admin/extra_datafiles file?

18 Feb 2020, 9:38 PM
#15
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: Fatal Error when purchasing Gift Certificate

interesting.... one of my test sites has the following:

MySQL Mode: NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION

when i add the mode of traditional into the admin area as described in the patch above, the mode changes as follows:

MySQL Mode: STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, TRADITIONAL, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION

which seems to be a more restrictive mode to operate.

just an FYI.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

18 Feb 2020, 9:47 PM
#16
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

lat9:

Does that show even after you've added that /admin/extra_datafiles file?

Yes. I haven't removed the file you said to upload.

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 10:00 PM
#17
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

carlwhat:

interesting.... one of my test sites has the following:

MySQL Mode: NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION

when i add the mode of traditional into the admin area as described in the patch above, the mode changes as follows:

MySQL Mode: STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, TRADITIONAL, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION

which seems to be a more restrictive mode to operate.

just an FYI.

I saw that https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_traditional

"Before MySQL 5.7.4, and in MySQL 5.7.8 and later, TRADITIONAL is equivalent to STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, and NO_ENGINE_SUBSTITUTION.

From MySQL 5.7.4 though 5.7.7, TRADITIONAL is equivalent to STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_AUTO_CREATE_USER, and NO_ENGINE_SUBSTITUTION. The NO_ZERO_IN_DATE, NO_ZERO_DATE, and ERROR_FOR_DIVISION_BY_ZERO modes are not named because in those versions their effects are included in the effects of strict SQL mode (STRICT_ALL_TABLES or STRICT_TRANS_TABLES). Thus, the effects of TRADITIONAL are the same in all MySQL 5.7 versions (and the same as in MySQL 5.6). "

Maybe that's why it isn't changing on my site (?).

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 10:08 PM
#18
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: Fatal Error when purchasing Gift Certificate

mvstudio:

I saw that https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_traditional

"Before MySQL 5.7.4, and in MySQL 5.7.8 and later, TRADITIONAL is equivalent to STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, and NO_ENGINE_SUBSTITUTION.

From MySQL 5.7.4 though 5.7.7, TRADITIONAL is equivalent to STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_AUTO_CREATE_USER, and NO_ENGINE_SUBSTITUTION. The NO_ZERO_IN_DATE, NO_ZERO_DATE, and ERROR_FOR_DIVISION_BY_ZERO modes are not named because in those versions their effects are included in the effects of strict SQL mode (STRICT_ALL_TABLES or STRICT_TRANS_TABLES). Thus, the effects of TRADITIONAL are the same in all MySQL 5.7 versions (and the same as in MySQL 5.6). "

Maybe that's why it isn't changing on my site (?).

perhaps. you can try:

define('DB_MYSQL_MODE', 'NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION');

see if it changes, and if it does then see if it fixes your original GC error.

if it does not change, then perhaps you host does not allow changing of the sql_mode, but that is pure conjecture on my part...

good luck!

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

18 Feb 2020, 10:24 PM
#19
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

carlwhat:

perhaps. you can try:

define('DB_MYSQL_MODE', 'NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION');

> 
> see if it changes, and if it does then see if it fixes your original GC error.
> 
> if it does not change, then perhaps you host does not allow changing of the sql_mode, but that is pure conjecture on my part...
> 
> good luck!

OMG!!! Yes!!! It worked!! And GC purchases go through as they should!! You're AWESOME!!! Thank you so much!!!!

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com

18 Feb 2020, 10:36 PM
#20
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

Re: Fatal Error when purchasing Gift Certificate

Spoke too soon. The button to release the GC is no where to be found. Can't release it at all.:no:

M.Valenti
Contemporary Artist - Entrepreneur
http://www.manuelavalenti.com - http://www.byvalenti.com