Support » Plugin: Flat Rate Shipping Plugin For WooCommerce » Default selected shipping?

  • Resolved one3rdnerd

    (@one3rdnerd)


    The option called “Default selected shipping?” doesn’t seem to make it show as the first option for me.

    On the site I am working on, under the standard WooCommerce Shipping Zones we have free local delivery as an option for the zones that aren’t covered.

    The local collection option shows first in the list rather than the shipping method created with this product.

    I turend the Default selected shipping option to YES but it doesn’t change that.

    Is that not what this is for? If not, how can I make sure this shipping method shows as the selected/top option out of the two?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Hitendra Chopda

    (@hitendra-chopda)

    Hello One3rdnerd,

    Thanks for reaching out to us.

    The option “Default selected shipping?” is used to make it selected for the selected shipping method.

    If you want to change the order of the shipping methods then, you need to add the below filter in your themes funtions.php file.

    /* Filter to change the order of defaul shipping and our advanced shipping */
    add_filter('woocommerce_package_rates', 'dotsotre_sort_shipping_methods', 10, 2);
    function dotsotre_sort_shipping_methods($available_shipping_methods, $package)
    {
    	// Arrange shipping methods as per your requirement
    	$sort_order	= array(
    		'advanced_flat_rate_shipping'	=>	array(),
    		'free_shipping'		=>	array(),
    		'local_pickup'		=>	array(),
    		'flat_rate'	=>	array(),		
    	);
    	// unsetting all methods that needs to be sorted
    	foreach($available_shipping_methods as $carrier_id => $carrier){
    		$carrier_name	=	current(explode(":",$carrier_id));
    		if(array_key_exists($carrier_name,$sort_order)){
    			$sort_order[$carrier_name][$carrier_id]	=		$available_shipping_methods[$carrier_id];
    			unset($available_shipping_methods[$carrier_id]);
    		}
    	}
    	// adding methods again according to sort order array
    	foreach($sort_order as $carriers){
    		$available_shipping_methods	=	array_merge($available_shipping_methods,$carriers);
    	}
    	return $available_shipping_methods;
    }

    In the above filter, you can change the order of the $sort_order array argument and it will work for you.

    Please do the above changes and let us know how it works.

    Best Regards,
    Hitendra & Dotstore Team

    Thread Starter one3rdnerd

    (@one3rdnerd)

    That works perfectly! Thank you for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.