Wordpress woocommerce - hide flat rate when free shipping -


i have 1 wordpress/woocommerce site. when user cart amount on 500 must have free shipping in cart subtotal. right have setup flat rate 25 , free shipping if amount more 500.

i google , add code functions.php still have same problem.

    function hide_all_shipping_when_free_is_available( $available_methods ) {  if( isset( $available_methods['free_shipping'] ) ) :  // free shipping array new array $freeshipping = array(); $freeshipping = $available_methods['free_shipping'];  // empty $available_methods array unset( $available_methods );  // add free shipping $avaialble_methods $available_methods = array(); $available_methods['free_shipping'] = $freeshipping;  endif;  return $available_methods; } 

i use wordpress woocommerce 2.3.8 on oxygen theme.

best regards

you're using old method, need use new one think.

copied woothemes website:

add_filter( 'woocommerce_package_rates','hide_shipping_when_free_is_available', 10, 2 );  function hide_shipping_when_free_is_available( $rates, $package ) {      // modify rates if free_shipping present     if ( isset( $rates['free_shipping'] ) ) {          // unset single rate/method, following. example unsets flat_rate shipping         unset( $rates['flat_rate'] );          // unset methods except free_shipping, following         $free_shipping          = $rates['free_shipping'];         $rates                  = array();         $rates['free_shipping'] = $free_shipping;     }      return $rates; } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -