Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2008
    Posts
    321
    Plugin Contributions
    1

    Default 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??

  2. #2
    Join Date
    Jul 2012
    Posts
    14,302
    Plugin Contributions
    17

    Default 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.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

  3. #3
    Join Date
    Jan 2004
    Posts
    65,266
    Blog Entries
    7
    Plugin Contributions
    226

    Default Re: Possible bug during coupon creation

    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Apr 2008
    Posts
    321
    Plugin Contributions
    1

    Default 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.

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    8,858
    Plugin Contributions
    70

    Default Re: Possible bug during coupon creation

    Quote Originally Posted by mvstudio View Post
    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).

  6. #6
    Join Date
    Apr 2008
    Posts
    321
    Plugin Contributions
    1

    Default Re: Possible bug during coupon creation

    Thank you Lat9! =)

 

 

Similar Threads

  1. Possible Coupon Bug?
    By ksoup in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 11
    Last Post: 25 Aug 2009, 04:57 AM
  2. validating custom field during account creation
    By ktrovato in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 31 Jul 2009, 04:35 AM
  3. Hide Telephone During Account Creation Issue
    By abhishek77 in forum General Questions
    Replies: 1
    Last Post: 5 May 2008, 12:30 PM
  4. Simple WYSIWYG Image Creation during order process?
    By silent0rigin in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 15 Dec 2007, 05:45 PM
  5. Possible coupon "" vs &pound bug
    By DMUK in forum Bug Reports
    Replies: 0
    Last Post: 6 Mar 2007, 11:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR