• Resolved migger

    (@migger)


    Hello
    Shipping price greater 100EUR is free – but less than 100 will cost 5.9 EUR Shipping!
    But why in the cart, the customer can still choose which shipping method he would like? He should not have the ability to determine the shipping price itself! What can I do?

    Thank you

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Coen Jacobs

    (@coenjacobs)

    So if I get it right, you want to disable the paid option if the free shipping option is available? You can do this by filtering the available shipping methods:

    add_filter( 'woocommerce_available_shipping_methods', 'cj_woocommerce_available_shipping_methods' );
    
    function cj_woocommerce_available_shipping_methods( $available_methods ) {
    	if ( isset( $available_methods['free_shipping'] ) ) {
    		foreach ( $available_methods as $key => $value ) {
    			if ( 'free_shipping' != $key ) {
    				unset( $available_methods[ $key ] );
    			}
    		}
    	}	
    
    	return $available_methods;
    }

    This will deactivate all shipping methods, except for free, when free is available. Place this code in a plugin, or in your (child) themes functions.php.

    Thread Starter migger

    (@migger)

    Cool! Thank you! exactly what I was looking for 🙂 It works …

    imfromio

    (@imfromio)

    You rock, Coen. I needed this, too and it works perfectly. Thanks!

    Valex2013

    (@valex2013)

    Hi. Thats really great! 🙂

    But…how is it possible to let “international_delivery” and “local_pickup” active?

    Thanks very much in advance! 😉

    Best regards!

    Coen Jacobs

    (@coenjacobs)

    Yeah you can narrow it down to pretty much all shipping methods, whatever you want. You just need to change the code to look for the right values.

    This code is based on making just free shipping available when it’s available, you will need another check to find when your two shipping methods should be available.

    In addition to Coen Jabobs and the question from Valex2013, this can, by changing the available methos in “unset($available_methods[‘local_delivery’]);”, see the difference:

    add_filter( 'woocommerce_available_shipping_methods', 'cj_woocommerce_available_shipping_methods' );
    
    	function cj_woocommerce_available_shipping_methods( $available_methods ) {
    	if ( isset( $available_methods['free_shipping'] ) ) {
    		foreach ( $available_methods as $key => $value ) {
    			if ( 'free_shipping' != $key ) {
    				unset( $available_methods[ 'local_delivery' ] );
    			}
    		}
    	}	
    
    	return $available_methods;
    	}
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Shipping Automatically set?’ is closed to new replies.