Jump to content

All in One Shipping Module Gets It's Rates Sorted


bsmither
 Share

Recommended Posts

The AIOS has Shipping Zones, which can be sorted, giving some sense of priority over how AIOS finds the first eligible zone to apply a collection of shipping rates to an order.

This task is then to sort the rates into an arbitrary order.

Please make the following edits:

In /language/module.definitions.xml, find near line 83:

<string name="notify_shipping_zone_sort_order"><![CDATA[Shipping zone sort order successfully updated.]]></string>

Add after:

<string name="notify_shipping_rates_sort_order"><![CDATA[Shipping rates sort order successfully updated.]]></string>


In /skin/admin/shipping_rates.tpl, find:

    <table class="list">
      <thead>
        <tr>

Add after:
          <th>{$LANG.all_in_one_shipping.arrange}</th>

Find:

      </thead>
      <tbody id="zone_{$zone.id}_rates">
        {if $RATES}

Change to:

      </thead>
      <tbody class="reorder-list" id="zone_{$zone.id}_rates">
        {if $RATES}

Find:

        {if $rate.zone_id == $zone.id}
        <tr>

Add after:

          <td align="center">
            <a href="#" class="handle"><img src="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/images/updown.gif" title="{$LANG.ui.drag_reorder}" /></a>
            <input type="hidden" name="rates_order[]" value="{$rate.id}" />
          </td>

Find:

        <tr>
          <td colspan="7">
            <a href="#" class="aios-add"><img src="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/images/add.png" alt="{$LANG.all_in_one_shipping.add_rows}" title="{$LANG.all_in_one_shipping.add_rows}" width="16" height="16" border="0" style="padding:0 5px;" />{$LANG.all_in_one_shipping.add_new_shipping_rates}</a>
          </td>
        </tr>

Before that, add:

      </tbody>
      <tbody class="list">


In /admin/index.inc.php, near line 418, find:

$rates = $GLOBALS['db']->select('CubeCart_shipping_rates', false, false, 'id');

Change to:

$rates = $GLOBALS['db']->select('CubeCart_shipping_rates', false, false, 'sort_order, id');


Near line 197, find:

	if ($updated) {
		$GLOBALS['gui']->setNotify($lang['all_in_one_shipping']['notify_shipping_zone_sort_order']);
	}
	$GLOBALS['cache']->clear();
	// httpredir(currentPage(array('tab')));
}

Add after:

/**/
//ALTER TABLE `CubeCart_shipping_rates`  ADD COLUMN `sort_order` INT(11) NOT NULL DEFAULT '1' AFTER `item_rate`;
$rates_order_update = array();
if (isset($_POST['rates_order']) && is_array($_POST['rates_order'])) {
	// Update rates order
	foreach ($_POST['rates_order'] as $key => $rate_id) {
		if ($rate_id != 0) {
			$rates_order_update[$rate_id]['sort_order'] = $key+1;
		}
	}
}
if (isset($_POST['rates_order']) && is_array($_POST['rates_order']) && Admin::getInstance()->permissions('settings', CC_PERM_EDIT)) {
	// Put changes into the database
	$rates_order_updated = false;
	foreach ($rates_order_update as $rate_id => $array) {
		if ($GLOBALS['db']->update('CubeCart_shipping_rates', $array, array('id' => $rate_id), true)) $rates_order_updated = true;
	}
	if ($rates_order_updated) {
		$GLOBALS['gui']->setNotify($lang['all_in_one_shipping']['notify_shipping_rates_sort_order']);
	}
	$GLOBALS['cache']->clear();
	// httpredir(currentPage(array('tab')));
}

/**/


In shipping.class.php, near line 54, find:

$this->_all_rates = $this->_db->select('CubeCart_shipping_rates', false, false, 'zone_id, id');

Change to:

$this->_all_rates = $this->_db->select('CubeCart_shipping_rates', false, false, 'zone_id, sort_order, id');

The database needs altering. You can do this in an external database management utility like phpMyAdmin.

Or you can do this in CubeCart's admin, Maintenance, Query Database tab. Above the Query box, there will be a mention of a table prefix if one is in use. Be sure to edit the query to include that prefix.

ALTER TABLE `CubeCart_shipping_rates`  ADD COLUMN `sort_order` INT(11) NOT NULL DEFAULT '1' AFTER `item_rate`;

I have not yet verified how this affects the listing shown to the customer at checkout. It should be sorted as desired.

Link to comment
Share on other sites

Well ... Once again Brian Thank You!!  I have only resorted one zone but wanted you to know it works great!  This will also be great if someone wanted to add a different shipping method but wanted to keep all the weights together.  Yeah!!!!  The only difference is the lines in admin/index.inc.php

In /admin/index.inc.php, near line 418, find:  My line 835

 

$rates = $GLOBALS['db']->select('CubeCart_shipping_rates', false, false, 'id');

 

Change to:

$rates = $GLOBALS['db']->select('CubeCart_shipping_rates', false, false, 'sort_order, id');

Near line 197, find:  My Line 393

                   if ($updated) {

                                      $GLOBALS['gui']->setNotify($lang['all_in_one_shipping']['notify_shipping_zone_sort_order']);

                   }

                   $GLOBALS['cache']->clear();

                   // httpredir(currentPage(array('tab')));

}

 

Add after:

/**/

//ALTER TABLE `CubeCart_shipping_rates`  ADD COLUMN `sort_order` INT(11) NOT NULL DEFAULT '1' AFTER `item_rate`;

$rates_order_update = array(); .............

 

Link to comment
Share on other sites

It looks like your line numbers have doubled. That indicates that the text editor you are using is double line spacing, or the file, from a previous edit, has double line spacing already.

The double line spacing happens when an editor wants to convert a Unix-style line-ending (x0A or LF) with a DOS-style line-ending (x0D0A or CRLF) and ends up putting both types at the end of the line.

Link to comment
Share on other sites

Now, in my opinion, all this mod needs a an "Edit All" functionally. If you have weights, by ounce and pound, for up to 30 pounds, with 3 different carriers, it gets old clicking the edit button for each one when the time comes to increase or decrease your rates based on the carrier annual rate change. I am very appreciative of the updates made up to now. Thanks again.

Link to comment
Share on other sites

We would want more details.

For example, would the "Edit All" button:
* simply convert all entries into text entry fields - which is what you would have to do for each row by clicking the edit icon, or
* add/subtract a fixed amount or persentage to all values

 

Link to comment
Share on other sites

Be able to change anything in each line like it is now and have a button where you could select all the lines at once if you wanted to, not just one, to  change the name given and / or the rate charged - manually, no percentages. Although some people might like the option to change all rates by a percentage.

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
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.

 Share

×
×
  • Create New...