After applying the coupon, the minimum amount of free shipping is not checked


  • Default avatar
    Jan    
     3 days ago
    0

    There is VM 3.6.2, the type of shipment method - weight_countries, the minimum amount of free delivery is 70 euros, Awocoupon 3.5.8, a coupon for a 40% discount.  
    The problem is the following: after applying the coupon, the minimum amount of free shipping is not checked. In some cases, after applying the discount coupon, the total amount becomes less than the minimum amount of free shipping. And in this case, need to add the shipment cost. I read this article: https://awodev.com/blog/virtuemart-minimum-amount-free-shipment-coupon it didn't help.
  • Your avatar
    seyi    
     3 days ago
    0

  • Default avatar
    Jan    
     2 days ago
    0

    Hi Seyi,

    I don't have this code in the plugins / vmshipment / weight_countries / weight_countries.php file. This code is missing in VM 3.6.2.
    When I tried the first method

    <?php
    //if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {
    $amount $this->getCartAmount($cart_prices);
    if (
    $method->free_shipment && $amount >= $method->free_shipment) {
    ?>


    I also tried to take the amount from billTotal, but this also did not work

    $amount = $this->getCartAmount($cart_prices['billTotal']);

    When a coupon is used, some complicated calculation takes place and the values of $ method-> free_shipment and $ cart_prices ['billTotal'] change. Without a coupon, the calculation is simple and correct.
  • Your avatar
    seyi    
     18 hours ago  last edited 18 hours ago
    0

    Hello,

    I just looked in Vrituemart 3.t6.2, and tlhe lateest, 3.6.10.  This line of code does exists:
    <?php
    if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {
    ?>

    If you do not have it, then you most likely have some customization in that file.  You could then back it up and get the file again from the virtuemart repository.

    And yes, this does not seem to work anymore:
    <?php
    $amount 
    $this->getCartAmount($cart_prices['billTotal']);
    ?>
    As you said, complicated Virtuemart calculations, which is why there is the alternate alternative to check the discount directly in AwoCoupon.

  • Default avatar
    Jan    
     17 hours ago
    0

    Hi,
    You misunderstood me. I wrote that there is no code for your link above

    <?php
                $orderamount_cond 
    = $this->testRange($cart_prices['salesPrice'],$method,'orderamount_start','orderamount_stop','order amount');
    ?>
  • Default avatar
    Jan    
     17 hours ago  last edited 17 hours ago
    0

    there is the alternate alternative to check the discount directly in AwoCoupon.
    How? How to fix the situation when after applying the coupon, the purchase amount becomes less than the minimum shipment amount?
  • Your avatar
    seyi    
     16 hours ago
    0

  • Default avatar
    Jan    
     11 hours ago
    0

    Hello Seyi,
    here is the entire function

    <?php
    function getCosts (VirtueMartCart $cart$method$cart_prices) {
            
            $amount 
    $cart_prices['salesPrice'];
            if ( function_exists'AC' ) ) {
                $awosess AC()->storediscount->get_coupon_session();
                if ( ! empty( $awosess ) ) {
                    $amount -= ( $awosess->product_discount $awosess->shipping_discount );
                }
            }
            if ($method->free_shipment && $amount >= $method->free_shipment) { 
                return 0.0;
            } else {
                if(empty($method->shipment_cost)) $method->shipment_cost 0.0;
                if(empty($method->package_fee)) $method->package_fee 0.0;
                return $method->shipment_cost $method->package_fee;
            }
        }
    ?>

    Is this correct?
  • Default avatar
    Jan    
     9 hours ago  last edited 9 hours ago
    0

    Great Seyi! It works! Thank you very much!