Latest News: (loading..)
Sign in to follow this  
Followers 0
cinolas

Adding a sort order to a shipping module that doesn't have one

4 posts in this topic

Posted (edited)

Hi,

 

I'm on 2.34 Bootstrap Gold and I'm using an old Canada Post XML shipping module that doesn't have a sort order field (or configuration entry).

 

Right now the module gets sorted on top and I'd like to change that, but I don't fully understand how the sorting of shipping modules works. The module doesn't create a SORT_ORDER entry on the configuration table during install, so I tried creating one manually but I don't know how to connect that row to the actual module so that the sort order value is summoned with the module.

 

I've looked at the chekckout_shipping page but saw nothing about sorting, so I thought maybe it was being done in the class but I don't see anything about sorting the modules there either.

 

I'm pretty sure this is easy if you know what you're doing, but I do not. I don't need a field on the admin interface, just some way of giving it a sort order.

 

Also, the shipping options show up from most expensive to least expensive on my checkout_shipping page, it selects the right one automatically, but I'd like to show the cheapest on top. How do I do that?

 

(if I could only find where these things are being sorted...)

 

 

Thanks!

Edited by cinolas

Share this post


Link to post
Share on other sites

Hi Nicolas,

 

if you open catalog/includes/modules/shipping/flat.php

and look for MODULE_SHIPPING_FLAT_SORT_ORDER this might give you a hint how it works.

 

Best regards

Christoph

Share this post


Link to post
Share on other sites

I did. My apologies for being dense here. I can see the configuration entries being created in the install function of shipping modules, and I can see that the CanadaPost shipping module doesn't create a row for the SORT_ORDER. So I went and created an entry in the Configuration table manually, but that doesn't change anything. How, or where, does that value get pulled to sort the modules on the checkout_shipping page?

Share this post


Link to post
Share on other sites

And did you change the module accordingly? There are three instances in example flat.php.

on line 23

      $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;

on 79 (this is for installing to db with sort order)

      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_FLAT_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");

and 87

      return array('MODULE_SHIPPING_FLAT_STATUS', 'MODULE_SHIPPING_FLAT_COST', 'MODULE_SHIPPING_FLAT_TAX_CLASS', 'MODULE_SHIPPING_FLAT_ZONE', 'MODULE_SHIPPING_FLAT_SORT_ORDER');

You could try to add an adaption of the first and last instance to your shipping module (as you entered a sort order already manually) and see what happens.

 

Best regards

Christoph

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0