WordPress.org

Support

Support » Plugins and Hacks » Conditional Free Shipping?

Conditional Free Shipping?

  • Hi,

    I am looking to offer free shipping on orders over $100 but only for specific products (parts) – For example if a customer purchases $100 worth of “replacement parts” then they will receive free shipping. Now, we also sell some other products that are above $100 but that do not qualify for free shipping because they are heavier than “replacement parts”.
    How can I go about this?
    I see that there is an easy way to set free shipping on orders above a specific amount but I don’t know how to exempt some heavier products that would make the order go over that amount.

    So what I need is to offer free shipping for some orders above $100 and still charge shipping for other orders over $100 if they contain specific items.

    Any ideas ? I would truly appreciate any help on this.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • *Basically i need some shipping classes to be able Overwrite the free shipping

    @p,
    at a design level, a way to approach this would be to offer free shipping all the time. Then at checkout init time, remove free shipping from the page, if cart <$100 or your heavy products are in the cart. You can search this forum for how to remove shipping options, and that’ll put you on the right track.

    I see what you mean…. Thanks, I will see where this takes me since im not too familiar but it might work. Thanks for your reply! 🙂

    In case anyone comes across this same issue in the future, i found my solution her:
    http://speakinginbytes.com/2013/11/disable-free-shipping-woocommerce/

    /**
     * Disable free shipping for select products
     *
     * @param bool $is_available
     */
    function my_free_shipping( $is_available ) {
    	global $woocommerce;
    
    	// set the product ids that are ineligible
    	$ineligible = array( '14009', '14031' );
    
    	// get cart contents
    	$cart_items = $woocommerce->cart->get_cart();
    
    	// loop through the items looking for one in the ineligible array
    	foreach ( $cart_items as $key => $item ) {
    		if( in_array( $item['product_id'], $ineligible ) ) {
    			return false;
    		}
    	}
    
    	// nothing found return the default value
    	return $is_available;
    }
    add_filter( 'woocommerce_shipping_free_shipping_is_available', 'my_free_shipping', 20 );

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Replacing the $ineligible array for your product number you will exempt those products from free shipping. Works like a charm.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditional Free Shipping?’ is closed to new replies.