News:

Looking for documentation? Take a look on our wiki

Main Menu

Free shipping limit, calculated after discount coupon is added

Started by betterlead, November 21, 2015, 22:07:42 PM

Previous topic - Next topic

betterlead

Hi, I'm not sure if this matter has been discussed in this forum before, but anyway, I'll give it a go:


I have set the free shipping limit to a certain sum. Let's say it's 500 SEK.
I have a lot of campaigns running with different rebates.
Now,,, I'd like the free shipping limit to be calculated on the total after any discount coupon has been used by the shopper.

Example: Customer buys for a total of 501 SEK - this gives her or him free shipping. Then the coupon is added and let's assume the total is now 400,80 SEK after a 20% rebate. Still the buyer gets free shipping. To sum up, I don't want the rebate to affect other than the goods bought.
Live site runs on Joomla 3.9.24 & VM 3.8.6 10373

PHP: 7.3.26

GJC Web Design

So it would seem either the shipping isn't recalculated after applying the coupon or the shipping plug isn't using the discounted total..

what shipping method and coupon ext. do u use?
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

betterlead

Standard built in VM coupon plugin, I recon. Shipment methods are four different but they are kind of standard... One, the main is a "Unity" shipment for all orders up to an amount of, actually 498 SEK. One is Collect at warehouse. One is free delivery in our city and the last one is one for international shipping with an extra 90 SEK. (Up to 1 kg.)

All four are: "By weight, ZIP and countries. weight_countries

Is that information enough, or am I not getting it?

Cheers & Thanks for helping.

Btw, big misstake, I forgot to mention the website's address,,, https://livingstudio.se


Live site runs on Joomla 3.9.24 & VM 3.8.6 10373

PHP: 7.3.26

GJC Web Design

OK .. so all standard...

if u switch on VM debug it will give a good amount of info on what the plugin is using for the free calc

its chk conditions uses the $cart_prices['salesPrice']...   

If i get time tomorrow will check if this is with/without coupon
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

betterlead

Live site runs on Joomla 3.9.24 & VM 3.8.6 10373

PHP: 7.3.26

betterlead

Live site runs on Joomla 3.9.24 & VM 3.8.6 10373

PHP: 7.3.26

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

hegbi

Hi betterlead
for VM2 you have a similar thread here, maybe it will help you...
http://forum.virtuemart.net/index.php?topic=108951.0

and for me this worked (J2.5 / VM 2.6.18)
in /plugins/vmshipment/weight_countries/weight_countries.php
changed line
if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {

with

//if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {
if ($cart->couponCode) {
    $amount = $cart_prices['salesPriceWithDiscount'];
} else {
    $amount = $cart_prices['salesPrice'];
}

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

betterlead

Live site runs on Joomla 3.9.24 & VM 3.8.6 10373

PHP: 7.3.26

mark R

Did you manager to get this working in VM3?

I have entered the above code but this does not solve the issue, I am using Awocoupon if that makes a difference.

Any help would be much appreciated.

Manrk
Seek and ye shall find.........
4 VM sites and counting

betterlead

Hi mark R

Sorry, I think I gave this one up.
So, let's bump this thread! :)

Any ideas, anybody?
Live site runs on Joomla 3.9.24 & VM 3.8.6 10373

PHP: 7.3.26

mark R

Not sure if this is right, as I am not a coder, but it appears to work.

Just needs some more testing, and a smarter eye then mine to have a quick look over it (as I may have missed something)

/plugins/vmshipment/weight_countries/weight_countries.php
        /**
         * @param VirtueMartCart $cart
         * @param                $method
         * @param                $cart_prices
         * @return int
         */
        function getCosts (VirtueMartCart $cart, $method, $cart_prices) {

                //if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {
        if ($cart->couponCode) {
                $amount = $cart_prices['salesPrice'] - $method->free_shipment;
                } else {
                $amount = $cart_prices['salesPrice'];
                        }
                if ($method->free_shipment && $amount >= $method->free_shipment) {
                        return 0.0;
                } else {
                        return $method->shipment_cost + $method->package_fee;
                }
        }


Any input / testing would be very appreciated.

Many thanks
Mark
Seek and ye shall find.........
4 VM sites and counting

mark R

Amended code appears to be working correctly, (shipping is calculated on total order and coupon value, if coupon is entered.)


       /**
         * @param VirtueMartCart $cart
         * @param                $method
         * @param                $cart_prices
         * @return int
         */
        function getCosts (VirtueMartCart $cart, $method, $cart_prices) {

                //if ($method->free_shipment && $cart_prices['salesPrice'] >= $method->free_shipment) {
        if ($cart->couponCode) {
                $amount = $cart_prices['salesPrice'] + $cart->pricesUnformatted['salesPriceCoupon'];
                } else {
                $amount = $cart_prices['salesPrice'];
                        }
                if ($method->free_shipment && $amount >= $method->free_shipment) {
                        return 0.0;
                } else {
                        return $method->shipment_cost + $method->package_fee;
                }
        }


I now have an issue that although the above works the ajax update when applying the coupon does not update the order details with the new shipping but it does update the shipping selection area? (I am using VP Onepage checkout).
If I click on the shipping method (not changing anything) it updates the order detail??

Any ideas?

Many thanks
Mark
Seek and ye shall find.........
4 VM sites and counting