Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2015
    Location
    Allentown, PA
    Posts
    33
    Plugin Contributions
    0

    Default Coupon % not working 1.5.6

    [Note: remember to include site URL, ZC version, list of plugins, PHP version, etc ... read the Posting Tips shown above for information to include in your post here. And, remove this comment before actually posting!]
    I just upgraded from 1.5.4 to 1.5.6 using softaculous (don't usually upgrade this way) and I've got everything working properly except for some reason every time I enter a coupon code with a % at the end ( I only offer % coupons ) when I save the coupon it changes it to a $ amount. I've been using zencart coupons for 10 years and never had this issue before.
    PHP version 7.1
    Thanks in advance for any suggestions
    JG64
    www.mark-a-hydrant.com

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,699
    Plugin Contributions
    123

    Default Re: Coupon % not working 1.5.6

    Confirmed. This is a bug. Working on it.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  3. #3
    Join Date
    Jul 2015
    Location
    Allentown, PA
    Posts
    33
    Plugin Contributions
    0

    Default Re: Coupon % not working 1.5.6

    swguy,

    Thank you for the quick reply!
    Any idea on a time frame, or workaround?
    The reason for the upgrade was a customer waiting on a coupon code to make a purchase -- and 2019 not being available in 1.5.4. Their preference is to purchase online, if possible.
    I am very appreciative for the dedication and hard work of all the smart people who make zen cart possible for the rest of us!
    JG64

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,699
    Plugin Contributions
    123

    Default Re: Coupon % not working 1.5.6

    Change admin/coupon_admin.php line 354 from

    $_POST['coupon_amount'] = (float)preg_replace('/[^0-9.%]/', '', $_POST['coupon_amount']);

    to

    Edit: See later post: #8
    Last edited by swguy; 4 Jan 2019 at 02:58 PM. Reason: Added cast to float
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  5. #5
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: Coupon % not working 1.5.6

    Quote Originally Posted by swguy View Post
    Change admin/coupon_admin.php line 354 from

    $_POST['coupon_amount'] = (float)preg_replace('/[^0-9.%]/', '', $_POST['coupon_amount']);

    to

    $_POST['coupon_amount'] = (float)preg_replace('/[^0-9.][\^%]/', '', $_POST['coupon_amount']);
    I haven't looked at other similar replacement functions in respect to this, but was wondering in light of the multi-country/multi-currency aspect, should the number only be filtered on periods or should it be periods and commas?
    (Assuming the remainder of the regex is correct)
    /[^0-9,.][\^%]/
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Jul 2015
    Location
    Allentown, PA
    Posts
    33
    Plugin Contributions
    0

    Default Re: Coupon % not working 1.5.6

    swguy,

    Thanks, but it didn't fix the problem.

    JG64

  7. #7
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,699
    Plugin Contributions
    123

    Default Re: Coupon % not working 1.5.6

    What PHP version are you using? Ugh this seems not to work in PHP7.2.
    Last edited by swguy; 4 Jan 2019 at 03:41 PM.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  8. #8
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,699
    Plugin Contributions
    123

    Default Re: Coupon % not working 1.5.6

    OK change the above to

    $is_pct = (substr($_POST['coupon_amount'], -1) == '%');
    $_POST['coupon_amount'] = (float)preg_replace('/[^0-9.]/', '', $_POST['coupon_amount']);
    if ($is_pct) $_POST['coupon_amount'] .= "%";
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  9. #9
    Join Date
    Jul 2015
    Location
    Allentown, PA
    Posts
    33
    Plugin Contributions
    0

    Default Re: Coupon % not working 1.5.6

    That did it.
    Thank you very much!

  10. #10
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,699
    Plugin Contributions
    123

    Default Re: Coupon % not working 1.5.6

    Great. This update has been submitted and will be part of 1.5.6a.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

 

 

Similar Threads

  1. Coupon Not Working
    By Jeff_Mash in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 3
    Last Post: 10 Nov 2011, 11:07 PM
  2. Coupon restrictions not working for my Free Shipping coupon
    By jeking in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 9
    Last Post: 11 Nov 2008, 07:41 PM
  3. coupon not working.
    By adornit in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 2
    Last Post: 26 Jul 2008, 02:41 PM
  4. Coupon Not Working
    By mccalld in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 25 Mar 2008, 05:00 PM
  5. coupon not working
    By eddierosenthal in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 3
    Last Post: 6 Oct 2007, 11:27 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