[Resolved] Automatic discount calculation incorrect


  • Default avatar
    brendon0    
     9 years ago
    0

    Hi there,

    An issue with automatic discounts was recently noticed by our client after we upgraded Redshop and AWO Coupon. There is a 5% discount set up for orders over $280 and a 10% discount for orders over $560. Here are the last two orders that came through that include a discount:


    ORDER A

    Subtotal: $267.70
    Shipping: $0.00
    Tax: $32.12
    Discount: $12.94
    Total: $286.89


    ORDER B

    Subtotal: $492.75
    Shipping: $0.00
    Tax: $59.13
    Discount: $22.99
    Total: $528.89


    I'm having trouble figuring out how these discount values are being calculated. Any help would be greatly appreciated.

    Thanks,

    Brendon
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    Will have to look directly in the database, I cannot tell from looking at those numbers. It is obviously trying to give a 5% discount in both orders but the discount value seems off.

    In the table #__awocoupon_history, there is the details field, which stores the cart/discount in json format. So you would need to pull the row that corresponds to the order, and then json decode it to see what is going on.
  • Default avatar
    brendon0    
     9 years ago
    0

    Hi Seyi,

    I've pulled the values you mentioned from the database and have saved them to a txt file on Dropbox. Here's a link to that txt file:

    https://www.dropbox.com/s/fjote6asxdo0ct7/Database%20Values.txt?dl=0

    I can't make much sense of it, but if you can have a look and see if anything is incorrect that would be much appreciated.

    Thanks,

    Brendon
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    After json decoding the text, it shows the total discount is

    before tax: 41.05
    after tax: 45.98

    This does not seem to match any of the original scenarios you posted. If you want me to look more into this particular order, can you give me more details of the order and what the discount should be?
  • Default avatar
    brendon0    
     9 years ago
    0

    Hi Seyi,

    Order B mentioned above has an order number of 1987, and that is the row in the database that this data was exported from. $22.99 is that discount amount that was applied to the order, but by my calculations it should have been $27.59 since it's supposed to be 5% of the order total after tax for any orders greater than $280 but less than $560.

    It doesn't match up at all as you mentioned. If you'd like I can create a staging site for you so you can take a closer look at the order and database.

    Cheers,

    Brendon
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    Yes, I think that is best.
  • Default avatar
    brendon0    
     9 years ago
    0

    Awesome. I've sent you the details in a PM.

    Cheers,

    Brendon
  • Your avatar
    seyi    
     9 years ago
    0

    Hi,

    Thanks for the admin access. Would need ftp access also. And checking the orders I do not see order 1987 as you mentioned in this post. Are there older orders on the staging site that have the same problem? If so can you point one out? Or maybe update the staging site with the production data?
  • Default avatar
    brendon0    
     9 years ago
    0

    Hi Seyi,

    My bad, I grabbed the wrong backup file when I created that staging site. I've now recreated it using a backup taken on the weekend. You can login using the same username/password I PM'ed you before. I've created FTP access for you as well which I'll PM you separately.

    Cheers,

    Brendon
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    Ok, took a look, got an explanation. In both the 5% and 10% coupons, you have these checked:
    - exclude specials
    - exclude discounted products

    For order 492, you have 2 products there at are considered special (marked as featured), products 311 and 313.

    So 492.75 - 82.25 - 0 (free sample) = 410.5 <=== subtotal
    410.5 * 1.12 = 459.76 <=== subtotal + tax
    459.75 * 0.05 = 22.988 <=== discount


    In the 286.89 order, product 117 is marked as featured, so
    267.70 - 36.7 = 231 <=== subtotal
    231 * 1.12 = 258.72 <=== subtotal + tax
    258.72 * 0.05 = 12.936 <=== discount

  • Default avatar
    brendon0    
     9 years ago
    0

    Hi Seyi,

    Thanks so much for figuring that out. It seems so obvious, but I probably wouldn't have caught it without your help. I'll make sure both of those coupons are set to include specials and discounted products.

    This continues to be one of the best supported extensions out there.

    Cheers,

    Brendon