Issue with discount amount and free shipping over £50


  • Default avatar
    garry2    
     25 days ago
    0

    Hello,
    We offer free shipping on orders over £50.
    Have a BOGOF (Buy X Get Y) coupon running on an item worth £15.

    Customer bought 2 products - subtotal £30.
    Coupon added 2 additional items making a subtotal £60. (correct)
    Then discount of £30 brings the subtotal to £30 again.
    However, when the customer is checking out, they are getting free shipping based on the £60 total.



    AWO Version: 3.6.0.3

    VirtueMart 3.8.4 10335

    Joomla! 3.9.26 Stable

    Using OPC from Rupostel


  • Your avatar
    seyi    
     24 days ago
    0

  • Default avatar
    garry2    
     24 days ago
    0

    It seems we have already changed this for a previous fix, but it is slightly different >


    $amount = $cart_prices['basePrice']; 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; }

  • Your avatar
    seyi    
     24 days ago
    0

    Yes, that looks correct.  Are you using standard shipping for free shipping?  And you have that code in
    \plugins\vmshipment\weight_countries\weight_countries.php

    And it is still not working?
  • Default avatar
    garry2    
     24 days ago
    0

    Hi Seyi,
    Yes, the code has been like this for a few months.
  • Default avatar
    garry2    
     23 days ago
    0

    Is there anything else we should look at to resolve ?
  • Your avatar
    seyi    
     23 days ago
    0

    Not sure, how did you set up the free shipping?
  • Default avatar
    garry2    
     18 days ago
    0

    Shipping is setup in VM with 'Minimum amount for Free Shipping' set as £50.


  • Your avatar
    seyi    
     17 days ago
    0

    Your shipping method looks different.  The solution given is for weight_countries, which has a shipping name of:


    Your method name is different.

  • Default avatar
    garry2    
     17 days ago
    0

    Hi Seyi - the used shipping method is a simple clone of the default shipping method. The fix above has already been applied to it.
  • Your avatar
    seyi    
     16 days ago
    0

    No idea then.  would need to debug it.  I can have a quick look if you can send me a private message with temp ftp/admin access.
  • Your avatar
    seyi    
     16 days ago
    0

    Thanks for the access, ran a test and realized the total is actually correct, just the display of the shipping cost is wrong:

    53.91 - 5.39 + 6.89 = 55.41

    Then I went back to the very first post in this topic and did the math, same thing:
    59.96 - 29.98 + 6.89 = 36.87

    So the total is correct, just the calculation of the shipping display is incorrect in the opc.  Fixed it by caching coupon value in the shipping method getCosts function:

    <?php
            
    //if ($method->free_shipment && $cart_prices['basePrice'] >= $method->free_shipment) {

            $amount $cart_prices['basePrice'];
            if (function_exists('AC')) {
                static $awosess null;
                if ( empty( $awosess ) ) {
                    $awosess AC()->storediscount->get_coupon_session();
                }
                if (!empty($awosess)) {
                    $amount -= ($awosess->product_discount $awosess->shipping_discount);
                }
            }

            if ($method->free_shipment && $amount >= $method->free_shipment) {
    ?>

    Now displays properly:
    fyoJFVm.png
  • Default avatar
    garry2    
     15 days ago  last edited 15 days ago
    0

    Seyi - perfect. Thank you for resolving this for me :)