Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2006
    Posts
    3
    Plugin Contributions
    0

    Default [Done v1.3.7] Coupon Admin - Percentage error with DECIMAL datatype

    Found a potential bug with the coupon administrator when using a percentage discount.

    I just downloaded Zen Cart and began playing with it before realizing it was not optimized for the newer versions of PHP/MySQL. Turns out that when I tried to create a coupon using a percentage, I got the following error:

    1366 Incorrect decimal value: '5.0000%' for column 'coupon_amount' at row 1

    Appears that the DECIMAL datatype in MySQL changed the way it is stored. Details can be found here:

    http://dev.mysql.com/doc/refman/5.0/...l-changes.html

    Long story short - DECIMAL is no longer stored as a string, but tables created in older versions of MySQL will keep the old behavior. I guess if someone upgrades to the latest version of MySQL, they won't notice this problem.

    Guess I have three options:

    Downgrade MySQL and probably PHP (most logical)
    Rewrite the code (me?..yea right)
    Change the coupon_amount datatype(tried, didn't work, not best solution anyway)

    Currently using:
    Apache 2.0.55
    PHP 5.1.6
    MySQL 5.0.26

    Any suggestions? Great application by the way. Y'all done good.

  2. #2
    Join Date
    Sep 2004
    Posts
    745
    Plugin Contributions
    4

    Default Re: Coupon Admin - Percentage error with DECIMAL datatype

    We are using very similar versions of PHP and MySQL

    MySQL 5.0.21-community
    Apache/2.2.2 (Win32) mod_ssl/2.2.2 OpenSSL/0.9.8b PHP/5.1.4

    and we use percentage coupons with no problem whatsoever, but we do comment out the following in the my.ini file.

    Code:
    #sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
    Perhaps this might be all that is necessary for you to do?

    Jeff

  3. #3
    Join Date
    Nov 2006
    Posts
    3
    Plugin Contributions
    0

    Default Re: Coupon Admin - Percentage error with DECIMAL datatype

    Re-installed with your suggestion and it worked. Appears I had a fourth option. Thanks for you help Jeff.

  4. #4
    Join Date
    Sep 2004
    Posts
    745
    Plugin Contributions
    4

    Default Re: Coupon Admin - Percentage error with DECIMAL datatype

    Glad that worked for you!

    You're very welcome...

    Jeff

  5. #5
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,896
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: Coupon Admin - Percentage error with DECIMAL datatype

    Hi the problem as suggested is caused by a tightening of the way mySql validates values to be entered into a DECIMAL field. As it is no longer a form of string any non numeric chars will cause an error,

    There is a simple code fix.

    in admin/coupon_admin.php at around line 227/228 and after these lines,

    PHP Code:
            $coupon_type "F";
            if (
    substr($_POST['coupon_amount'], -1) == '%'$coupon_type='P'
    add

    PHP Code:
            $_POST['coupon_amount'] = preg_replace('/[^0-9.]/'''$_POST['coupon_amount']); 
    HTH

  6. #6
    Join Date
    Nov 2006
    Posts
    3
    Plugin Contributions
    0

    Default Re: Coupon Admin - Percentage error with DECIMAL datatype

    Thanks Wilt. I reinstalled after changing the my.ini back to the original settings, but I added the % into the preg_replace function:

    preg_replace('/[^0-9.%]/', '',

    worked great.

 

 

Similar Threads

  1. Sales Tax incorrect with percentage discount coupon
    By coryinit in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 8
    Last Post: 5 Apr 2010, 03:40 AM
  2. [Done v1.3.9] Gift voucher / coupon redemption error
    By talisman-studios in forum Bug Reports
    Replies: 1
    Last Post: 13 May 2008, 04:07 PM
  3. Replies: 0
    Last Post: 7 Feb 2008, 11:39 AM
  4. Combining a Sale with a Percentage Off Coupon
    By mlm2005 in forum Setting Up Specials and SaleMaker
    Replies: 9
    Last Post: 4 Sep 2006, 04:42 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