• Resolved Group Of Oceninfo

    (@princebhalani143)


    Hello Team,

    After WooCommerce recent update my shipping method is not working as I’ve removed state field from the checkout page and kept only country field, previously when user were selecting country it was showing the shipping method.

    While adding state field and someone is selecting the state it’s working normally as I don’t want to keep that based on state but based on Region/Country level shipping method. or in-short Remove State field from shipping calculator only use country field for the calculation

    My shipping zone settings : https://i.imgur.com/1Ag7fWu.jpg

    Can you please help me to get shipping methods based on country level back instead of country and state?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Matt

    (@boxwebdesign)

    Same issue here (www.fortuny.shop) after latest upgrade, the shipping calculator is showing “No shipping options were found for …” until the full address is filled.

    Hope there will be a quick fix on this as it’s making waste a lot of time to both company employees to get shipping quotations and customers of the website.

    Thanks

    Thread Starter Group Of Oceninfo

    (@princebhalani143)

    Hi @boxwebdesign

    I’ve found the solution after comparing old and new WooCommerce files issue is due to new code added under woocommerce\includes\class-wc-shipping.php line no 287 to 304 where it’s looking for the Country + State if both are found then it’s returning the shipping information.

    I’ve commented below code and change the return value true and it’s returning the expected result for me, you can give a try if same solution is working for you as well. There is no changes done in the back-end.

    public function is_package_shippable( $package ) {
    	if ( empty( $package['destination']['country'] ) ) {
    		return true;
    	}
    	// $country = $package['destination']['country'];
    
    	// $countries = array_keys( WC()->countries->get_shipping_countries() );
    	// if ( ! in_array( $country, $countries, true ) ) {
    		// return false;
    	// }
    
    	// $states = WC()->countries->get_states( $country );
    	// if ( is_array( $states ) && ! empty( $states ) && ! isset( $states[ $package['destination']['state'] ] ) ) {
    		// return false;
    	// }
    
    	//return true;
    }
    Matt

    (@boxwebdesign)

    THANK YOU!
    This was extremely helpful!
    In my case I edited the code in a slightly different way, here it is:

    
    public function is_package_shippable( $package ) {
    if ( empty( $package['destination']['country'] ) ) {
    	return false;
    }
    $country = $package['destination']['country'];
    $countries = array_keys( WC()->countries->get_shipping_countries() );
    if ( ! in_array( $country, $countries, true ) ) {
    	return false;
    }
    /*
    $states = WC()->countries->get_states( $country );
    if ( is_array( $states ) && ! empty( $states ) && ! isset( $states[ $package['destination']['state'] ] ) ) {
    	return false;
    }
    */
    
    return true;
    }
    

    I left uncommented the country part and now it’s working as expected.
    Thank you very much for your help!

    • This reply was modified 4 years, 8 months ago by Matt.
    Thread Starter Group Of Oceninfo

    (@princebhalani143)

    @boxwebdesign Good to hear that solution work for you, Yeah that’s also perfect solution if you want user to select country and then show shipping info.

    As my client were interested to show throughout the cart + checkout without selecting the location so I’ve used other solution.

    Thread Starter Group Of Oceninfo

    (@princebhalani143)

    @boxwebdesign New WooCommerce 4.0.1 no changes required as they’ve added fix.
    * Fix – Made the package shipping check more permissive. #25916

    Matt

    (@boxwebdesign)

    Great, thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Shipping zones requiring states’ is closed to new replies.