Shipping sort order in admin

When setting up shipping in amdin in weight order, after saving the sort order gets all messed up, see attached.
I d rather it sort by weight ascending, or even by price ascending if possible.makes it easier to edit in future
12kg - 23.99kg
24kg - 35.99kg
36kg - 47.99kg
and so on
see attached messed up Screenshot by Lightshot


Try replacing the following code:

        if (rateValues && rateValuesKeys.length > 0) {
            rateValuesKeys.sort().forEach(key => {
                data.rateValue = rateValues[key];
                fn_add_tr_to_table_conditions(data, $newConditionTable, false);

with this code:

        if (rateValues && rateValuesKeys.length > 0) {
            var collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
            rateValuesKeys.sort( => {
                data.rateValue = rateValues[key];
                fn_add_tr_to_table_conditions(data, $newConditionTable, false);

in the js/tygh/backend/shipping_rates.js file. Then clear the cache of your installation and check if sorting is working as intended.

Thanks, but just a word of warning, it seems this will delete all exisiting rates, so they will need to be added again’

When I was trying these changes in my installation, it haven’t affected existing rates. And overall these changes could not affect existing data. Unfortunately I don’t know what happened in your case.

OK thanks, Ill take a look

You are correct the alteration works fine, I deleted another line by mistake


1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.