Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sort shipping modules?


lorax

Recommended Posts

I've modified the State Based Rates contribution so that I have 4 copies of it. One for each different shipping method I need (ground, 2 day, etc..).

 

They each installed fine and work fine but they don't display on checkout_shipping in the order I want them to. I tried adding sort_order values to the configuration table since I don't see a way to do it using the shipping module controls in Admin.

 

I was going to do a sort on the value that the quotes function returns but it's a multi-dimensional array and I can't find a way to tell sort what field I want to sort on.

 

I'm beginning to think the only way to do this is to parse through the array and build a new one before outputting it to screen. Then I can sort on any field I wish. Does this seem like a reasonable way to approach this or is there an easier way?

Apathy is a dominant gene - mutate.

Link to comment
Share on other sites

lorax,

From what I can tell, the order of the shipping models display is determined by the order of the shipping model filenames in the $this->modules array in the quote() function in the shipping class. The population of this array is based on the MODULE_SHIPPING_INSTALLED configuration variable. This variable is updated whenever the module's sort order is changed. If you change a sort order on one of the installed modules and look at this field in the DB you will see that it changes too. As such, setting the sort order should work and I am unclear as to why yours wouldn't. Maybe it has something to do with the fact that you have 4 copies of the same thing.

 

I played around with just making a sort($this->modules) statement at the beginning of the quote() function, this will sort the shipping modules by the module FILENAME -- which may or may not be what you want. I think you could probably just re-assign each row's value manually to this array in the order you want it in. I believe it only has one element for each row, the module filename (i.e. zones.php).

Link to comment
Share on other sites

Thanks Oppen,

Bingo! I simply renamed the shipping modules to fit the sort order I wanted and it worked perfectly.

 

Oh... and I had to modify the sections where the code called for the filenames as well!

Edited by lorax

Apathy is a dominant gene - mutate.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...