How to adapt Virtuemart's Minimum Amount For Free Shipping so it can handle different amounts for different countries:
Now, before we begin, the usual warning: Backup the files you are going to be working with. This is a hack of the global.php file to allow different free shipping amounts for different countries.
The file you'll be working with: /administrator/components/com_virtuemart/global.php
First, in the Virtuemart administration page, go to the Store -> Edit Store page and set the base amount you want to use for 'free shipping'. Usually, this should be the value you set for the most commonly used free amount you want to use (ie. your home country).
Now, open up global.php, and search for:
So, what happens is the script checks to see what country it is. If it is not Canada, then free shipping is negated (set to zero). If it is Canada, then free shipping is set to whatever is in the VM admin backend.
Now, say you want the USA to have a different value before free shipping applies. This is what that code would look like:
That's it. Now, in the above example, if the country being shipped to is the USA, then the free shipping minimum is set to $75. Otherwise, it is set to whatever you set in the Virtuemart backend.
Now, before we begin, the usual warning: Backup the files you are going to be working with. This is a hack of the global.php file to allow different free shipping amounts for different countries.
The file you'll be working with: /administrator/components/com_virtuemart/global.php
First, in the Virtuemart administration page, go to the Store -> Edit Store page and set the base amount you want to use for 'free shipping'. Usually, this should be the value you set for the most commonly used free amount you want to use (ie. your home country).
Now, open up global.php, and search for:
$vendor_freeshipping = $db->f("vendor_freeshipping");The example will show how to detect for a country and hard-code in a new value for free-shipping. Ie. The amount set in the VM Admin page will be the base amount for free shipping in Canada. First, I'll show what to do when you want to eliminate free shipping to all countries, but one.
if ($_SESSION['auth']["country"] != "CAN") { $vendor_freeshipping = "0"; } else { $vendor_freeshipping = $db->f("vendor_freeshipping"); }
So, what happens is the script checks to see what country it is. If it is not Canada, then free shipping is negated (set to zero). If it is Canada, then free shipping is set to whatever is in the VM admin backend.
Now, say you want the USA to have a different value before free shipping applies. This is what that code would look like:
if ($_SESSION['auth']["country"] == "USA") { $vendor_freeshipping = "75"; } else { $vendor_freeshipping = $db->f("vendor_freeshipping"); }
That's it. Now, in the above example, if the country being shipped to is the USA, then the free shipping minimum is set to $75. Otherwise, it is set to whatever you set in the Virtuemart backend.
Comments
Post a Comment