Having a free shipping coupon when cart is 0$


  • Default avatar
    nicolas4    
     10 years ago
    0

    Seyi,

    We're having a hard time figuring how to fix this and I thought you might be in the loop.

    Please have a look at these sceenshots. You will find 3 cases with my analysis. Coupons used : parent coupon, 3 coupons, free game (value 25% if in cart), free shipping (100%) and 20% off on all other products (BTW, your AWO coupon system is simply the best in the world, so powerful!!).

    https://drive.google.com/file/d/0B3JHnWnMtsGaOHBybUl2OVlHRWc/edit?usp=sharing
    https://drive.google.com/file/d/0B3JHnWnMtsGaYktRemhPNThKNkU/edit?usp=sharing
    https://drive.google.com/file/d/0B3JHnWnMtsGaaGhsdjNiWXYtT2c/edit?usp=sharing

    The issue is coming when we have a shipping cost + free shipping coupon applied. As the coupon gives a equivalent discount (instead of removing the shipping cost, which would be different), the total cart discount becomes higher than the cart value, making some wrong tax calculations.

    I do not know which part of the system "make it wrong": VM? AWO?

    So actually, the system do this :

    (subtotal1) - discount = subtotal2
    (subtotal2 + tax) + (shipping + tax) = total

    We are trying to make the following :

    (subtotal1 + shipping) - discount = subtotal2
    subtotal2 + taxes = total

    Can you please help me to pinpoint where these calculations are made? That would be greatly appreciated.

    Thanks.
    Nicolas
  • Default avatar
    nicolas4    
     10 years ago
    0

    Seyi,

    I discussed with the programmer here and we have a new approach. Changing the calculations is, I think, the wrong way to see this.

    The issue is the shipping discount is added to the marchandise discount, so the cart total is below 0$.

    I think that the shipping coupon should override Flex2 (in our case) and put the shipping cost down to 0$ (instead of having a shipping cost of 8$ + 8$ discount).

    Doing this will also solve an issue we have on Paypal: even if we tell our clients "free shipping", there's still a shipping cost displayed on the page.

    https://drive.google.com/file/d/0B3JHnWnMtsGaMWZQVHFwYVRSbmM/edit?usp=sharing

    Thanks.
  • Your avatar
    seyi    
     10 years ago
    0

    You are correct. For virtuemart 1.1.x the shipping discount should be subtracted directly from the shipping cost and not into the product discount. If you have not fixed it already here is the fix:

    in www/administrator/components/com_awocoupon/helpers/estore/virtuemart1/couponhandler.php, find the function finalize_coupon and delete it. Then add this in its place:
    <?php
        
    function finalize_coupon($master_output) {
            
    $session_array $this->calc_coupon_session($master_output);
            if(empty(
    $session_array)) return false;
            
            
    $coupon_discount_total 0;
            foreach(
    $session_array['processed_coupons'] as $coupon) {
                
    $coupon_discount_total += $coupon['is_discount_before_tax']==1
                        
    $coupon['product_discount_notax']
                        : 
    $coupon['product_discount']
                ;
            }
            
            
            
    $_SESSION['coupon_redeemed'] = true;
            
    $_SESSION['coupon_id'] = $session_array['coupon_id'];
            
    $_SESSION['coupon_code'] = $session_array['coupon_code'];
            
    $_SESSION['coupon_discount'] = $coupon_discount_total ;
            
    $_SESSION['coupon_type'] = 'gift'// always call cleanup function
            
            // shipping discount
            
    if( !empty( $_REQUEST['shipping_rate_id'] )) {
                
    $rate_array explode'|'urldecode(vmGet($_REQUEST,"shipping_rate_id")) );
                
    $total = (float) $rate_array[3];
                
                if(!empty(
    $total)) {
                    
    $coupon_value $coupon['shipping_discount'];
                                
                    if( 
    $total $coupon_value ) {
                        
    $coupon_value = (float)$total;
                    }
                    
                    
    // insert new shipping total back into cart
                    
    $rate_array[3] = $total $coupon_value;
                    
    $_REQUEST['shipping_rate_id'] = urlencode(implode('|',$rate_array)); // reconstruct shipping id
                    
    $_SESSION[$_REQUEST['shipping_rate_id']] = 1// needed to register shipping as valid
                
    }
            }
            
            
            
            if(
    $this->refresh_cartJFactory::getApplication()->redirect('index.php?option=com_virtuemart&page=shop.cart');
            return 
    true;
            
    //return $coupon_codes;
            
        
    }
    ?>
  • Default avatar
    nicolas4    
     10 years ago
    0

    Seyi,

    Thank you VERY VERY much, we were looking at this file to find a solution, and ... boom! here it is.

    I am trying right now.

    Nicolas
  • Default avatar
    nicolas4    
     10 years ago
    0

    FIXED !! Thanks a lot Seyi !
    Nicolas
  • Your avatar
    seyi    
     10 years ago
    0

    Great, glad to hear its working well now.
  • Default avatar
    nicolas4    
     9 years ago
    0

    Hello Seyi,

    I had 2 issues since that message above and I am writing you to get your quick advice on how to diagnose. Both issues were the same.

    Today, I client used a master coupon with 75$ off (1) and free shipping (2). AWO substracted 65$ from the order (total was 65$), so the new cart total was 0$. When FLEX2 looked if we had to add shipping fee, as total was 0$, it added 8$ to cart. AWO looked at shipping costs and put shipping costs to 0$.... only in AWO.

    That means that if I look at coupon history, AWO informs me that the free shipping coupon (2) was used with 8$ discount + 65$ discount on marchandise (1). When I look at the order, the shipping costs are still there.

    We used 165 master coupons like these and we had 2 issues.

    What could it be? Where should I look at? Could it be a browser refresh issue?

    Thank you very much.
  • Your avatar
    seyi    
     9 years ago
    0

    Hello,

    This is Virtuemart 1.x right? Can you first go to awocoupon->installation check and verify that everything that needs installing is installed?


    There is an extension writtng for flex, but I am not flex2. You can see the extension here:
    www/administrator/components/com_awocoupon/helpers/estore/virtuemart1/shipping/flex.php

    I dont know if this is the problem, but maybe copying flex and updating it for flex2 might fix the issue.