Possible bug during coupon creation
Clean installation of zencart 1.5.6a.
I'm getting an error while creating a coupon for free shipping only. Discount coupons for certain amount or percentage discount can be created just fine.
Blank page with the following error displays after confirmation
WARNING: An Error occurred, please refresh the page and try again.If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
I've tried filling in all fields and I get the same error.
Log file
[B][21-May-2019 10:41:29 America/Detroit] Request URI: /... ADMIN .../coupon_admin.php?action=update_confirm&oldaction=new&cid=1&page=1, IP address: 76.112.20.152
#1 trigger_error() called at [/... CATALOG .../includes/classes/db/mysql/query_factory.php:171]
#2 queryFactory->show_error() called at [/... CATALOG .../includes/classes/db/mysql/query_factory.php:143]
#3 queryFactory->set_error() called at [/... CATALOG .../includes/classes/db/mysql/query_factory.php:270]
#4 queryFactory->Execute() called at [/... ADMIN .../includes/functions/database.php:51]
#5 zen_db_perform() called at [/... ADMIN .../coupon_admin.php:445]
--> PHP Fatal error: 1366:Incorrect decimal value: '' for column `xxxxx`.`coupons`.`coupon_amount` at row 1 :: insert into coupons (coupon_code, coupon_amount, coupon_product_count, coupon_type, uses_per_coupon, uses_per_user, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_start_date, coupon_expire_date, date_created, date_modified, coupon_zone_restriction, coupon_calc_base, coupon_order_limit, coupon_is_valid_for_sales, coupon_active) values ('FREESHIPPING', '', '0', 'S', '100000000', '100000000', '100', '', '', '2019-05-21', '2020-05-21', now(), now(), '5', '0', '0', '1', 'Y') ==> (as called by) /... ADMIN .../includes/functions/database.php on line 51 <== in /... CATALOG .../includes/classes/db/mysql/query_factory.php on line 171.
Any idea what could be happening??
Re: Possible bug during coupon creation
An amount of "nothing" is not being stored/converted to a value of 0. Instead it is being attempted to be stored as a string of empty quotes. The database does not like trying to change data types.
Would recommend at line 409 of admin/coupon_admin.php
to change:
Code:
zen_db_prepare_input($_POST['coupon_amount']),
To:
Code:
convertToFloat($_POST['coupon_amount']),
This may clear the single error/issue, but there may be another further down the line.
Re: Possible bug during coupon creation
Re: Possible bug during coupon creation
Thank you for the help DrByte.
In my version of that file admin/coupon_admin.php I have this line of code
PHP Code:
if ( ($_POST['back_x']) || ($_POST['back_y']) ) {
$_GET['action'] = 'new';
} else {
instead of the one in the link
PHP Code:
if ( (!empty($_POST['back_x'])) || (!empty($_POST['back_y'])) ) {
$_GET['action'] = 'new';
} else {
I'm wondering if I should replace that line of code too.
Re: Possible bug during coupon creation
Quote:
Originally Posted by
mvstudio
Thank you for the help DrByte.
In my version of that file admin/coupon_admin.php I have this line of code
PHP Code:
if ( ($_POST['back_x']) || ($_POST['back_y']) ) {
$_GET['action'] = 'new';
} else {
instead of the one in the link
PHP Code:
if ( (!empty($_POST['back_x'])) || (!empty($_POST['back_y'])) ) {
$_GET['action'] = 'new';
} else {
I'm wondering if I should replace that line of code too.
@mvstudio, I'd go ahead and make that change as well. Its purpose is to provide the same processing, but checking firs tto see that the variables exist (so your store doesn't trigger multiple PHP warnings for more recent PHP versions).
Re: Possible bug during coupon creation