Automatic coupon not working properly


  • Default avatar
    rob320    
     2 years ago
    0

    I have virtuemart 2.0.24c and awo coupon pro 2.2.3

    i've setup 3 automatic coupons with diferent minimum order price and 1 coupon wich the client can enter in the shop.
    i allowed multiple coupons, 2 all, 1 automatic and 1 regular.

    now when i order enough to get the 1st automatic coupon everithing works fine, but when i change the amount of product to raise the order price to get the next automatic discount coupon it takes the 2nd coupon and after calculate the discount it takes the 1st coupon en calculate the discount over the already discounted price and gives extra discount.

    example
    when i order above €100,- i get 5% discount
    when i order above €200,- i get 10% discount
    when i order above €300,- i get 15% discount

    when i enter the coupon code 5%off i get 5% discount

    when i place an order for let say €400,- i get (€400-€40=€360-€18=€342) and not €400-€60=€340

    When i disable multiple coupons, the automatic discounts works properly, but then i'm not able to enter the manual discount coupon.
  • Your avatar
    seyi    
     2 years ago
    0

    Hello,

    Im sorry but I am having a hard time following.

    So in your example, instead of first giving a 15% discount and then a 5% discount:
    400 - 60 = 340 - 17 = 323

    You are receiving a 10% discount and then a 5% discount?
    400 - 40 - 360 - 18 = 342

    ?

    How did you set up the automatic discount coupon(s) and what order did you put them in?
  • Default avatar
    rob320    
     2 years ago
    0

    I'm sorry.
    let me try to explain again.

    i only need 1 automatic coupon, the height of the coupon discount depends on the total order amount.
    besides the automatic discount, the client can enter a manual coupon with 5% discount.

    now when i suppose to recieve 15% discount automaticly the system takes first 10% and after that 5%. instead of the 15% at once.

    i have 3 automatic coupons. first one is 15% discount at minimum order of €300,- , second 10% at minimum order of €200,- and thirth 5% at minimum order of €100,-.
    in the configuration i put multiple coupons enable, set automatic coupons to 1, All to 2, general coupons to 1 and giftcard to 0.

    i hope its clear enough for you now
  • Your avatar
    seyi    
     2 years ago
    0

    Hello,

    So if you enter over €300 in the cart, and also the 5% discount. You receive 10% and then 5%? Or 15% and then 5%?

    The coupon discounting system is built in such a way that the customer can never over use a coupon. So if the are 3 coupons to discount, the system first discounts the first coupon, then uses the new total to discount the second, and then uses the new total to discount the third. This is by design.
  • Default avatar
    rob320    
     2 years ago
    0

    I understand that the system applies the first and then the second.
    but that is not the problem.

    if i enter over €300 in the cart the system automaticly applies first 10% discount and then 5% discount instead of only the 15% discount.
    it takes the second and then the third discount coupon.

    because clients are able to use the extra 5% discount coupon i can't allow just 1 coupon. if i just allow 1 coupon the system works fine and takes the right automatic coupon.
    the extra 5% discount is not always needed.

    if i order above €100,- i get automaticly 5% discount
    if i order above €200,- i get automaticly 10% discount
    if i order above €300,- i get automaticly 15% discount

    that is how it supposed to work.
    when i have a coupon code, i can enter that one for an extra 5% discount.

    therefor i need tot enable multiple coupons and then the system takes then 2 automatic discount rules and aplies them after eachother. but that not what i want

    i hope it now clear enough explained
  • Your avatar
    seyi    
     2 years ago
    0

    Ok, I think I get it now. The problem is it is treating one of the automatic coupons as a normal coupon.

    Will have a look and update when I have something.
  • Your avatar
    seyi    
     2 years ago
    0

    Hello,

    Think i found a solution to the problem, it requires modification of code. The file is
    www/administrator/components/com_awocoupon/helpers/estore/estorecouponhandler.php

    around line 257 is this
    <?php
                                $db
    ->setQuery('SELECT function_type FROM #__awocoupon WHERE coupon_code="'.awolibrary::dbEscape($submitted_coupon_code).'"');
                                
    $test $db->loadResult();
                                if(!empty(
    $test)) $multiple_coupons[$test=='giftcert' 'giftcert' 'coupon'][] = $submitted_coupon_code;
    ?>


    Change it to this
    <?php
                                $check_if_auto 
    false;
                                foreach(
    $auto_codes as $auto_code) {
                                    if(
    $auto_code->coupon_code==$submitted_coupon_code) {
                                        
    $check_if_auto true;
                                        break;
                                    }
                                }
                                if(!
    $check_if_auto) {
                                    
    $db->setQuery('SELECT function_type FROM #__awocoupon WHERE coupon_code="'.awolibrary::dbEscape($submitted_coupon_code).'"');
                                    
    $test $db->loadResult();
                                    if(!empty(
    $test)) $multiple_coupons[$test=='giftcert' 'giftcert' 'coupon'][] = $submitted_coupon_code;
                                }
    ?>


    Around line 222 is this
    <?php
            
    if(empty($coupon_awo_entered_coupon_ids) && empty($auto_codes)) return $this->return_false('errNoRecord');
    ?>


    Right after that add this:
    <?php
            
    if(empty($auto_codes)) $auto_codes = array();
            foreach(
    $auto_codes as $auto_code$multiple_coupons['auto'][] = $auto_code->coupon_code;
    ?>


    And around line 205 is this:
    <?php
                    
    foreach($coupon_session['processed_coupons'] as $k=>$r) {
    ?>


    Right after that, add this:
    <?php
                        
    if($r['isauto']) continue;
    ?>


    And that should do it. If you need help adding the code, I can.