Advertisement
Guest User

Hide Standard Shipping

a guest
Oct 16th, 2014
1,171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. // Hide ALL shipping options when free shipping is available
  2. add_filter( 'woocommerce_available_shipping_methods', 'hide_all_shipping_when_free_is_available' , 10, 1 );
  3.  
  4. /**
  5. * Hide ALL Shipping option when free shipping is available
  6. *
  7. * @param array $available_methods
  8. */
  9. function hide_all_shipping_when_free_is_available( $available_methods ) {
  10.  
  11.     if( isset( $available_methods['free_shipping'] ) ) :
  12.  
  13.         // Get Free Shipping array into a new array
  14.         $freeshipping = array();
  15.         $freeshipping = $available_methods['free_shipping'];
  16.  
  17.         // Empty the $available_methods array
  18.         unset( $available_methods );
  19.  
  20.         // Add Free Shipping back into $avaialble_methods
  21.         $available_methods = array();
  22.         $available_methods[] = $freeshipping;
  23.  
  24.     endif;
  25.  
  26.     return $available_methods;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement