[Skip to main content](#vessel-content)

#   Trying to sort UPS option lowest to highest with lowest selected by default

##

- **[a2zcs](/forum/user/33209-a2zcs "View a2zcs's Profile")**
- [![a2zcs's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar33209.jpg)](/forum/user/33209-a2zcs "View a2zcs's Profile") Topic Author
- [ Offline](/forum/user/33209-a2zcs)

Less More

- Posts: 298
- Thank you received: 7
-
-

6 years 4 months ago [\#321294](#321294) by [a2zcs](/forum/user/33209-a2zcs "View a2zcs's Profile")  *[Trying to sort UPS option lowest to highest with lowest selected by default](/forum/28-shipping-methods/900279-trying-to-sort-ups-option-lowest-to-highest-with-lowest-selected-by-default#321294 "-- url of the page with the problem -- :   aquacorals.com  -- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.2.31 -- Browser(s) name and version -- : Firefox  I've used the steps in topic:   www.hikashop.com/forum/shipping-methods/...sorted-by-price.html  before, successfully, but for some reason now these same steps are not working. Is there a different way to achieve this?")* was created by *[a2zcs](/forum/user/33209-a2zcs "View a2zcs's Profile")*

-- url of the page with the problem -- : [ aquacorals.com](http://aquacorals.com)
-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.19
-- PHP version -- : 7.2.31
-- Browser(s) name and version -- : Firefox

I've used the steps in topic: [ www.hikashop.com/forum/shipping-methods/...sorted-by-price.html](https://www.hikashop.com/forum/shipping-methods/881066-ups-shipping-options-not-sorted-by-price.html)
before, successfully, but for some reason now these same steps are not working. Is there a different way to achieve this?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvOTAwMjc5LXRyeWluZy10by1zb3J0LXVwcy1vcHRpb24tbG93ZXN0LXRvLWhpZ2hlc3Qtd2l0aC1sb3dlc3Qtc2VsZWN0ZWQtYnktZGVmYXVsdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

6 years 4 months ago [\#321335](#321335) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[Trying to sort UPS option lowest to highest with lowest selected by default](/forum/28-shipping-methods/900279-trying-to-sort-ups-option-lowest-to-highest-with-lowest-selected-by-default#321335 "-- url of the page with the problem -- :   aquacorals.com  -- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.2.31 -- Browser(s) name and version -- : Firefox  I've used the steps in topic:   www.hikashop.com/forum/shipping-methods/...sorted-by-price.html  before, successfully, but for some reason now these same steps are not working. Is there a different way to achieve this?")*

Hello,

Can you show me the path of the file that you have edited and also which change did you applied to that file ? Thank you.

Kind regards,
Mohamed.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvOTAwMjc5LXRyeWluZy10by1zb3J0LXVwcy1vcHRpb24tbG93ZXN0LXRvLWhpZ2hlc3Qtd2l0aC1sb3dlc3Qtc2VsZWN0ZWQtYnktZGVmYXVsdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[a2zcs](/forum/user/33209-a2zcs "View a2zcs's Profile")**
- [![a2zcs's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar33209.jpg)](/forum/user/33209-a2zcs "View a2zcs's Profile") Topic Author
- [ Offline](/forum/user/33209-a2zcs)

Less More

- Posts: 298
- Thank you received: 7
-
-

6 years 4 months ago [\#321363](#321363) by [a2zcs](/forum/user/33209-a2zcs "View a2zcs's Profile")  Replied by *[a2zcs](/forum/user/33209-a2zcs "View a2zcs's Profile")* on topic *[Trying to sort UPS option lowest to highest with lowest selected by default](/forum/28-shipping-methods/900279-trying-to-sort-ups-option-lowest-to-highest-with-lowest-selected-by-default#321363 "-- url of the page with the problem -- :   aquacorals.com  -- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.2.31 -- Browser(s) name and version -- : Firefox  I've used the steps in topic:   www.hikashop.com/forum/shipping-methods/...sorted-by-price.html  before, successfully, but for some reason now these same steps are not working. Is there a different way to achieve this?")*

The first change I made in the "administrator\components\com_hikashop\classes\shipping.php" file and changed the line :
Code:

uasort($usable_methods, array($this, "sortShipping")); To: //uasort($usable_methods, array($this, "sortShipping"));

Then in the plugins/hikashopshipping/ups/ups.php I added these lines: Code:

function array_sort($array, $on, $type, $order = SORT_ASC){ if(empty($array)) return array(); $new_array = array(); $sortable_array = array(); foreach ($array as $key =&gt; $value) { if($value-&gt;shipping_type == $type) $sortable_array[$key] = $value-&gt;shipping_price; } switch ($order) { case SORT_ASC: asort($sortable_array); break; case SORT_DESC: arsort($sortable_array); break; } foreach ($sortable_array as $k =&gt; $v) { $new_array[$k] = $array[$k]; } return $new_array; }

JUST AFTER Code:

curl_close($session); }

AND ADDED:

Code:

$new_usable_rates = $this-&gt;array_sort($new_usable_rates, 'shipping_price', 'ups', SORT_DESC);

Just before these lines :
Code:

foreach($new_usable_rates as $i =&gt; $usable_rate) { if(isset($usable_rate-&gt;shipping_price_orig) &#124;&#124; isset($usable_rate-&gt;shipping_currency_id_orig)){ if($usable_rate-&gt;shipping_currency_id_orig == $usable_rate-&gt;shipping_currency_id) $usable_rate-&gt;shipping_price_orig = $usable_rate-&gt;shipping_price; else $usable_rate-&gt;shipping_price_orig = $currencyClass-&gt;convertUniquePrice($usable_rate-&gt;shipping_price, $usable_rate-&gt;shipping_currency_id, $usable_rate-&gt;shipping_currency_id_orig); } $usable_rates[$usable_rate-&gt;shipping_id] = $usable_rate; $cache_usable_rates[$usable_rate-&gt;shipping_id] = $usable_rate; }

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvOTAwMjc5LXRyeWluZy10by1zb3J0LXVwcy1vcHRpb24tbG93ZXN0LXRvLWhpZ2hlc3Qtd2l0aC1sb3dlc3Qtc2VsZWN0ZWQtYnktZGVmYXVsdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

6 years 4 months ago -  6 years 4 months ago [\#321419](#321419) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[Trying to sort UPS option lowest to highest with lowest selected by default](/forum/28-shipping-methods/900279-trying-to-sort-ups-option-lowest-to-highest-with-lowest-selected-by-default#321419 "-- url of the page with the problem -- :   aquacorals.com  -- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.2.31 -- Browser(s) name and version -- : Firefox  I've used the steps in topic:   www.hikashop.com/forum/shipping-methods/...sorted-by-price.html  before, successfully, but for some reason now these same steps are not working. Is there a different way to achieve this?")*

Hello,

That patch should have worked 2 years ago, but a lot of changes were applied to the shipping system and also to the UPS shipping method.

The solution now will be to directly edit the "#__hikashop_config" table of your website's database using phpmyadmin and add a row with :
- "config_namekey" set to **sort\_shipping\_by\_price**
- "config_value" set to **1**

Kind regards,
Mohamed.

Last edit: 6 years 4 months ago by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile").

The following user(s) said Thank You: [a2zcs](/forum/user/33209-a2zcs "View a2zcs's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI4LXNoaXBwaW5nLW1ldGhvZHMvOTAwMjc5LXRyeWluZy10by1zb3J0LXVwcy1vcHRpb24tbG93ZXN0LXRvLWhpZ2hlc3Qtd2l0aC1sb3dlc3Qtc2VsZWN0ZWQtYnktZGVmYXVsdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.062 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
