Title: Special Shipping Class
Last modified: August 22, 2016

---

# Special Shipping Class

 *  [DarkNova](https://wordpress.org/support/users/darknova11/)
 * (@darknova11)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/special-4/)
 * Hi!
 * I need help/suggestion/idea 🙂
 * I would like to have as followed:
 * free shipping for all my products with minimum order amount of $300 and all bellow
   shall have $30 fixed shipping price – and that is easy done and it works fine…
 * but the problem that I have and want to find a solution is that I would like 
   to add $30 fixed shipping price to my ON SALE products no matter how big order
   amount is
 * I can’t go and use additional cost cause when a user orders items that are on
   the sale and the order amount is smaller than $300 then that extra cost will 
   be applied and the shopper with the regular shipping cost and the user will end
   up paying more…
 * but this way all the orders above $300 will be billed with extra $30 that I have
   added in to additional cost and updated all the on sale products with that shipping
   class…
 * Please need help and/or suggestions.
 * Thanks
 * [https://wordpress.org/plugins/woocommerce/](https://wordpress.org/plugins/woocommerce/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [DarkNova](https://wordpress.org/support/users/darknova11/)
 * (@darknova11)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/special-4/#post-5567619)
 * I have managed to find a solution and it’s this:
 *     ```
       // Hide standard shipping option when free shipping is available
       add_filter( 'woocommerce_available_shipping_methods', 'hide_standard_shipping_when_free_is_available' , 10, 1 );
   
       /**
       * Hide Standard Shipping option when free shipping is available
       *
       * @param array $available_methods
       */
       function hide_standard_shipping_when_free_is_available( $available_methods ) {
       	global $woocommerce;
       	$cart = $woocommerce->cart;
       	$content = $cart->get_cart();
       	$sale_products = array_filter( wc_get_product_ids_on_sale() );
   
       	$hasPopust = false;
   
       	foreach ($content as $cartitem) {
       		if(in_array($cartitem['product_id'], $sale_products)){
       			$hasPopust = true;
       			break;
       		}
       	}
   
       	if($hasPopust){
       		unset( $available_methods['free_shipping'] );
       	}
       	if(isset( $available_methods['free_shipping']) && isset($available_methods['flat_rate']) && !$hasPopust) {
       		// remove standard shipping option
       		unset( $available_methods['flat_rate'] );
       	}
   
       return $available_methods;
       }
       ```
   
 * Add this to funcions.php in your child theme.

Viewing 1 replies (of 1 total)

The topic ‘Special Shipping Class’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [flat rate](https://wordpress.org/support/topic-tag/flat-rate/)
 * [free shipping](https://wordpress.org/support/topic-tag/free-shipping/)

 * 1 reply
 * 1 participant
 * Last reply from: [DarkNova](https://wordpress.org/support/users/darknova11/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/special-4/#post-5567619)
 * Status: not resolved