WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Shipping class to be able Overwrite free shipping? (2 posts)

  1. Palexandra
    Member
    Posted 8 months ago #

    Like the title says im looking to find a way for some shipping classes to overwrite the "free shipping on orders over $100". How can I achieve this?

    Any help would be appreciated.

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

  2. Palexandra
    Member
    Posted 8 months ago #

    Just in case anybody comes across this issue i found my solution here:

    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.

Reply

You must log in to post.

About this Plugin

About this Topic