Skip to main content

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

More
6 years 3 months ago #321294 by a2zcs
-- 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?

Please Log in or Create an account to join the conversation.

More
6 years 3 months ago #321335 by Mohamed Thelji
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 or Create an account to join the conversation.

More
6 years 3 months ago #321363 by a2zcs
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 => $value) { if($value->shipping_type == $type) $sortable_array[$key] = $value->shipping_price; } switch ($order) { case SORT_ASC: asort($sortable_array); break; case SORT_DESC: arsort($sortable_array); break; } foreach ($sortable_array as $k => $v) { $new_array[$k] = $array[$k]; } return $new_array; }

JUST AFTER
Code:
curl_close($session); }


AND ADDED:

Code:
$new_usable_rates = $this->array_sort($new_usable_rates, 'shipping_price', 'ups', SORT_DESC);

Just before these lines :
Code:
foreach($new_usable_rates as $i => $usable_rate) { if(isset($usable_rate->shipping_price_orig) || isset($usable_rate->shipping_currency_id_orig)){ if($usable_rate->shipping_currency_id_orig == $usable_rate->shipping_currency_id) $usable_rate->shipping_price_orig = $usable_rate->shipping_price; else $usable_rate->shipping_price_orig = $currencyClass->convertUniquePrice($usable_rate->shipping_price, $usable_rate->shipping_currency_id, $usable_rate->shipping_currency_id_orig); } $usable_rates[$usable_rate->shipping_id] = $usable_rate; $cache_usable_rates[$usable_rate->shipping_id] = $usable_rate; }

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago - 6 years 2 months ago #321419 by Mohamed Thelji
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 2 months ago by Mohamed Thelji.
The following user(s) said Thank You: a2zcs

Please Log in or Create an account to join the conversation.

Time to create page: 0.248 seconds
Powered by Kunena Forum