Thread Starter
lewis
(@lewiswolk)
Yes after seeing your support for the free version I have no doubt you will get it to work 🙂
Thread Starter
lewis
(@lewiswolk)
and I just ordered – Looking forward to your awesome support 🙂
Thread Starter
lewis
(@lewiswolk)
Pro version worked first shot with no complications lol.
Glad I bought it.
Quick question is there any way to show the rates cheapest to most expensive instead of most expensive to cheapest and have the cheapest as the default instead of the most expensive ?
https://ibb.co/R7hK1xL
Plugin Support
lusp
(@lusp)
Hi @lewiswolk,
I believe these two snippets should do the job. If you add them to the functions.php file of theme/child-theme your shop is currently using or insert them via e.g. the Code Snippets plugin, the first one:
add_filter( 'woocommerce_package_rates' , 'sort_woocommerce_available_shipping_methods', 10, 2 );
function sort_woocommerce_available_shipping_methods( $rates, $package ) {
// if there are no rates don't do anything
if ( ! $rates ) {
return;
}
// get an array of prices
$prices = array();
foreach( $rates as $rate ) {
$prices[] = $rate->cost;
}
// use the prices to sort the rates
array_multisort( $prices, $rates );
// return the rates
return $rates;
}
should result in sorting all the available shipping methods starting from the cheapest one, and the second:
function default_cheapest_shipping_method( $current_chosen_method, $available_methods ) {
$selection_priority = get_option( 'woocommerce_shipping_method_selection_priority', array() );
if ( ! empty( $available_methods ) ) {
// Is a method already chosen?
if ( ! empty( $current_chosen_method ) && ! isset( $available_methods[ $current_chosen_method ] ) ) {
foreach ( $available_methods as $method_key => $method ) {
if ( strpos( $method->id, $current_chosen_method ) === 0 ) {
return $method->id;
}
}
}
// Order by priorities and costs
$prioritized_methods = array();
foreach ( $available_methods as $method_key => $method ) {
// Some IDs contain : if they have multiple rates so use $method->method_id
$priority = isset( $selection_priority[ $method->method_id ] ) ? absint( $selection_priority[ $method->method_id ] ): 1;
if ( empty( $prioritized_methods[ $priority ] ) ) {
$prioritized_methods[ $priority ] = array();
}
$prioritized_methods[ $priority ][ $method_key ] = $method->cost;
}
ksort( $prioritized_methods );
$prioritized_methods = current( $prioritized_methods );
asort( $prioritized_methods );
return current( array_keys( $prioritized_methods ) );
}
return false;
}
add_filter('woocommerce_shipping_chosen_method', 'default_cheapest_shipping_method', 10, 2);
will make the cheapest one selected by default.
I hope the solution I suggested above helped. Please also mind that if you own an active PRO plugin subscription you can contact us directly with all your questions and doubts at https://flexibleshipping.com/support/
Kind regards,
Łukasz
Thread Starter
lewis
(@lewiswolk)
trying now and yes I purchased the pro version today and LOVE IT !!!
I can now offer my Canadian shoppers canada post shipping service and my US customers UPS rates.
Thread Starter
lewis
(@lewiswolk)
worked like a charm – great support btw 🙂
https://ibb.co/sV5QxNG
Plugin Support
lusp
(@lusp)
Thank you very much Lewis for the kind words. We are doing our best! 🙂
Thread Starter
lewis
(@lewiswolk)
question ,
for the pro version which I purchased. Can you add an option to admin to select how many rates to show ?
I think instead of all the rates showing the admin should have option to display the amount they want like the 3 cheapest rates , 4 cheapest rates etc.
Is this possible.
Also with your snippets I can have the cheapest rate selected by default however I am unable to sort the rates from cheapest to most expensive without fatal error on my site.
So still waiting for support on that fix.
best,
Lewis