WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Shipping Automatically set? (7 posts)

  1. migger
    Member
    Posted 1 year ago #

    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/

  2. Coen Jacobs
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. migger
    Member
    Posted 1 year ago #

    Cool! Thank you! exactly what I was looking for :-) It works ...

  4. imfromio
    Member
    Posted 1 year ago #

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

  5. Valex2013
    Member
    Posted 1 year ago #

    Hi. Thats really great! :)

    But...how is it possible to let "international_delivery" and "local_pickup" active?

    Thanks very much in advance! ;)

    Best regards!

  6. Coen Jacobs
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  7. Maurice van Opdorp
    Member
    Posted 5 months ago #

    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;
    	}

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic