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

  1. Palexandra
    Posted 2 years 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.


  2. Palexandra
    Posted 2 years ago #

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


    */ 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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic