• Resolved babbancarter

    (@babbancarter)


    How can I get rid of some of the fields on the product pages on the shipping calculator? For example I only ship to one country so don’t need to show the country. Also, need to get rid of the state and city if I am only using table rates with postcodes. Ideally I just want to keep it simple with only a postcode field. Appreciate your input.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author rajeshsingh520

    (@rajeshsingh520)

    Hi,

    You can use this filter function to hide the different field
    you have to insert this code function in your the theme functions.php file

    
    /** to hide country */
    add_filter( 'woocommerce_shipping_calculator_enable_country', '__return_false' );
    
    /** to hide state */
    add_filter( 'woocommerce_shipping_calculator_enable_state', '__return_false' );
    
    /** to hide city */
    add_filter( 'woocommerce_shipping_calculator_enable_city', '__return_false' );
    
    /** to hide post code */
    add_filter( 'woocommerce_shipping_calculator_enable_postcode', '__return_false' );
    
    Thread Starter babbancarter

    (@babbancarter)

    Hi rajeshsingh520,

    Thanks for your reply. I apologize as I am new to this.

    Unfortunately, after hiding the fields i’m not getting the correct output of the shipping cost. Im using the Flexible Shipping plugin by WP Desk to calculate the cost using the states as zones. Unfortunately, after I hide the fields, it is not bypassing those fields in the background.

    Are you please able to suggest a way to make this work?

    Thank You!

    Plugin Author rajeshsingh520

    (@rajeshsingh520)

    Hi,

    Sorry we cant get it to work like that

    if your shipping zones are based on state then you cant hide those field as WooCommerce will need those field to decide the zone and show shipping method as per that zone

    that is the reason we have not given the option of hiding the field in the plugin as every one have different setup for shipping zones

    Thread Starter babbancarter

    (@babbancarter)

    Thanks for your quick reply mate. I know its not your job but any chance you could give me some pointers on how to achieve this? I have already tried to change the zones to postcodes only but I still cant make it work with the fields hidden. Seems like it still needs to pick the state from the dropdown and have the country selected even though i have only AUSTRALIA set as the country I specifically sell to and ship to the countries i sell to.

    Is there a way I can get in touch with you directly?

    Plugin Author rajeshsingh520

    (@rajeshsingh520)

    Hi,

    WooCommerce do not go ahead with post code based zone matching until there is Country and state information given

    you can use the below solution to hide the Country and City field but state and post code will be required

    /**
    This code will auto set Australia in your customer country
    */

    add_action( 'woocommerce_init',  'startSession_202106' );
    function startSession_202106(){
    	if(function_exists('WC') && isset(WC()->session)){
    		if ( !is_admin() && !WC()->session->has_session() ) {
    			WC()->session->set_customer_session_cookie( true );
    			WC()->customer->set_country("AU");
    		}
    	}
    }

    /**
    you can use below css code to hide the country fiend as that is auto set to Australia
    */

    
    #calc_shipping_country{
    display:none;
    }
    

    /**
    use below code to hide the city field
    */

    
    add_filter( 'woocommerce_shipping_calculator_enable_city', '__return_false' );
    
    Thread Starter babbancarter

    (@babbancarter)

    Thank you for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Remove Fields’ is closed to new replies.