WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
WooCommerce - Hiding free shipping from certain products (7 posts)

  1. yifa
    Member
    Posted 1 year ago #

    I have an online store where most items are under $50. There are flat rate postage costs, and if you spend over $100 you get free shipping.

    The problem is I do have a handful of products that are more than $100, and are rather large and/or heavy, thus the postage rates will be higher.

    I did the obvious and added custom additional postage charges to those particular items, however, when in the cart, the 'free shipping' is still an option for them to select because they are over the $100.

    My question is...is it possible to hide, or deactivate, the free shipping for these specific products?

    Thanks in advance!

    Ben

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

  2. samueljeden
    Member
    Posted 1 year ago #

    Hi,

    Do you have the other rates setup so that they only show on the products that are larger/heavy and do not qualify for free shipping?

    if so the following code should work, as it hides free shipping when there are other available methods.

    http://docs.woothemes.com/document/hide-other-shipping-methods-when-free-shipping-is-available/

    That needs to be placed in your themes functions.php file.

    Thanks :)

  3. yifa
    Member
    Posted 1 year ago #

    Sorry, I'm not quite sure what you mean? All I've done is create certain shipping classes, say "heavy", and attached the shipping class to whatever product is overly heavy.

    I do have that code you provided already, and it works well, but that is something different.

    So say I have a product that is $599, so obviously it qualifies for the over $100 free shipping. On the cart page, the only option it has is free shipping. So somehow I have to exclude this product from qualifying for free shipping and display a flat rate instead (based on the shipping class I attached).

  4. Palexandra
    Member
    Posted 7 months ago #

    Hi Yifa, im having this exact same problem.... have you found a way to make this work?

  5. bheadrick
    Member
    Posted 7 months ago #

    How's this:
    http://bryanheadrick.com/product/woocommerce-disable-free-shipping/

    This will automatically disable/hide the free shipping method if any product is in the cart that is in one of the selected shipping classes or product categories

  6. Palexandra
    Member
    Posted 7 months ago #

    I found a snippet to do this for free simply by adding it to your function.php file:

    **
    */ 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 );

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

    Found this info here: http://speakinginbytes.com/2013/11/disable-free-shipping-woocommerce/

    Very helpful. Hope it helps those that are looking for a free solution.

  7. Patrick Rauland
    Member
    Posted 6 months ago #

    Hey @Palexandra glad you found that info on my blog - and glad it's helping. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic