Coupon Value being rounded off


  • Default avatar
    maggoo    
     14 years ago
    0

    Hi, great component.

    I have the following behavior with awocoupon free version.

    I have 5 coupons, starting at 20.00, next at 40.00 etc. The discounts increases with each coupon.

    When i put a product in the basket of 19.95 i can enter the first coupon that starts at 20.00. The discount is being deducted then. When i change the amount to 20.01 i can't use the coupon code, with a product of 19.95 in my basket. Obviously the latter behavior is as expected but the first behavior isn't.

    It seems that the amounts are being rounded off in a unexpected fashion. Any advice on this?
  • Your avatar
    seyi    
     14 years ago
    0

    I do not think i quite follow. Can you rephrase the problem? Also what kind of coupon are you using, percentage or amount?
  • Default avatar
    maggoo    
     14 years ago
    0

    Ok, let me rephrase. I am using percentage coupon btw.

    The first coupon can be used from 20.00 euro, you will get a 2% discount. When i put 1 product in the cart, costing 19.95, i can use the coupon, and get a 2% discount. The coupon should be valid from 20.00 and upwards, not with 19.95.

    So i got a bit confused and tried some other values.

    Now i set the coupon to be valid from 20.01 and upwards, again with a 2% discount. Then i put 1 product in my cart, costing 19.95. Now, when i enter the 2% discount coupon i get the expected behavior, namely that the discount isn't valid (or can not be found in vm terms).

    I also have coupons for amounts from 40, 60, 80 and 100, with different discounts. Same applies here. For instance when i have a total of 39,95 in my cart i can use the 40 euro (total order) discount, which shouldn't be of course. But when i put the starting amount to 40.01 all is well.

    So, i suspect that the amount in the cart is being rounded off upwards. 19.95 in your cart is being rounded off to 20.00 and therefore the coupons applies. As a workaround i put the starting value at 20.01, 19.95 becomes 20.00, which isnt enough for the discount to apply, because that starts at 20.01.

    Uff, it isn't the most elegant way of describing my problem:), but hopefully it makes enough sense.

    TIA.

    ps. all is functional when i put the starting amount on 20.01, 40.01 etc, but that's not exactly what you would expect.
  • Your avatar
    seyi    
     14 years ago
    0

    Thanks for taking the time to re-explain the problem. I was able to reproduce it and yes, you are right, it is a rounding issue. I will update the free version in the next 48 hours, but if you cant wait, here is the fix:

    in www/administrator/components/awocoupon/assets/ps_coupon_process.php, on line 128
    change
    <?php
    if (!empty($coupon_row->min_value) && round($d['total'])<$coupon_row->min_value) {
    ?>

    to
    <?php
    if (!empty($coupon_row->min_value) && round($d['total'],2)<$coupon_row->min_value) {
    ?>
  • Default avatar
    maggoo    
     14 years ago
    0

    Thanks seyi, good to know that i am not crazy:)
    Also good to see that you are on top of things, when the coupons hit off on my site i will surely come back for the pro version.
    Thanks again.