Post by opencartisalright » Thu Aug 25, 2011 8:21 pm

If you have weight based shipping enabled, and you have say three Geo Zones set up (ex. USA Regular Mail, USA Priority Mail, USA Express Mail), this vQmod will sort them by price (from lowest to highest).

Weight based shipping sorts alphabetically by default, which can sometimes make the most expensive shipping option appear first! This vQmod will fix that so that the lowest priced shipping option will appear first. For example:

Regular Mail - $3.99
Priority Mail - $6.99
Express Mail - $9.99

and so on...

Attachments

Weight Based Shipping Sort by Price OC 1.5.1.1


Active Member

Posts

Joined
Mon Feb 21, 2011 4:09 am

Post by Johnathan » Thu Aug 25, 2011 10:33 pm

Just to note, I mention this method here: http://forum.opencart.com/viewtopic.php ... 854#p92781
and it can be used on any shipping method. In the /catalog/model/shipping/ file just add:

Code: Select all

function comparecost ($a, $b) {
    return $a['cost'] > $b['cost'];
}
uasort($quote_data, 'comparecost'); 
before the code:

Code: Select all

$method_data = array( 

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by opencartisalright » Fri Aug 26, 2011 12:29 am

And a great contribution it is Johnathan.

I turned it into a vQmod for my store just for weight based shipping, but as you mention it can be used for all the shipping methods. I just didn't want to fiddle with all the other shipping methods since i'm only using the weight based one. :)

Active Member

Posts

Joined
Mon Feb 21, 2011 4:09 am

Post by OCMaster597 » Wed Oct 23, 2019 8:34 am

[SOLVED] & tested on version 1.5.x
To sort 'weight based shipping options' by price instead of alphabetically.
You will need to do three small easy steps :

First....
1. Go to => /public_html/catalog/model/shipping/weight.php
FIND
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone ORDER BY name");


REPLACE WITH
//$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone ORDER BY name");
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone ORDER BY geo_zone_id");


and save.

Next....
2. Go to your store admin panel - www.yourdomainname.com/admin/index.php? ... n/geo_zone
and create all new GeoZones that you want to use. (this is important because if you reuse your old GeoZones you will lose the weight based rates data on your weight-based shipping option) Lets not worry about adding any zones to these new GeoZones you will use for weight based shipping yet.

Finally...
3. First step is to backup your database. (you can do that inside your admin panel and save the .sql file to your desktop or external hard-drive)
Get into your 'phpMyAdmin' and click on your database. When the database is expanded, look for your "geo_zone" and click on it.
Once loaded, look on the right side (browse tab) you will see list of all your current geo_zones, your new geo_zones and their corresponding "geo_zone_id" in a numeric value. Start by finding your most expensive geo_zone for the weight based shipping option. Click edit, and change the geo_zone_id to 90, then click go, so it saves and goes back to previous screen. Then find your next most expensive geo_zone for the weight based shipping option. Click edit, and change the geo_zone_od to 89, then click go, so it saves and goes back to previous screen. And just keep going with numbering your new geo_zones in numeric value.

Example list of new geo_zones we used for weight based shipping, changing their ID:

Standard Shipping (geo_zone_id=87)
Priority Shipping (geo_zone_id=88)
Two-Day Shipping (geo_zone_id=89)
Next Day Shipping (geo_zone_id= 90)

You can create as many geo_zones as you'd like and just number them starting with the most expensive with the highest number and keep going down in numbers as you get towards you least expensive. (I started with 90 as my highest id) I suggest you use the higher number also.

From there you are pretty much all set!

Now you can go back to your www.yourdomainname.com/admin/index.php? ... n/geo_zone
and start adding zones to your new geo_zones.


Hope this helps someone, seems not a lot of answers available for this simple task. Cheers! ;)

Newbie

Posts

Joined
Thu Nov 30, 2017 2:53 am
Who is online

Users browsing this forum: No registered users and 9 guests