• Resolved Rose

    (@thorned-rose)


    I have a product A and B in my store. Product A can only be picked up via Local Pickup (“must be picked up”). Product B can either be shipped via flat rate or picked up (“can be picked up). However, when both products are added to the cart, Product A shows up with local pickup and Product B has a “Shipping 2” flat rate shipping applied to it. If product A and B are in the cart together, local pickup should be the only option. Is this a bug or is there some setting I am missing? TIA!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Rose

    (@thorned-rose)

    I am wondering if this is a bug because even if I set Product B to “Must be picked up” Shipping 2 still appears but now has “There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.” beside it.

    Thread Starter Rose

    (@thorned-rose)

    Further to this, if I use Product C and Product D, I do not get this issue. Product B is a duplicate of Product D so I am wondering if in duplicating the product, a bug has occurred. I am continuing to test and will next try completely deleting Product B and creating it from scratch.

    Thread Starter Rose

    (@thorned-rose)

    Ok, with Product C and D, it comes up with “These items are for pick up.
    Click if you want these items to be shipped.” If you click to select shipping, then it comes up with the option of pickup or flat rate shipping. If I add code to remove the flat rate shipping when pickup is selected, Shipping 2 still appears but beside it is “There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.”

    Further info on the code I have tried here: https://stackoverflow.com/questions/52218255/woocommerce-when-local-pickup-plus-is-selected-remove-all-other-shipping-me

    Hi there

    Are you using per product shipping as WooCommerce core does not come with this by default. What plugin are you using to accomplish this, and how do you have your Zones configured? You can enable Debug under WooCommerce > Settings > Shipping > Shipping Options and this can tell you what is being pulled and why. Please let us know what it pulls up!

    You may be able to achieve this by creating a Shipping Class and attaching it to whichever you need to do the opposite.

    Thread Starter Rose

    (@thorned-rose)

    The site was using Local Pickup Plus. Turns out there was a bug with it. I disabled LPP, added WC’s default local pickup as a shipping method to local shipping zone, then added the following code to disable flat rate shipping when local pickup is available.

    function hide_shipping_method_based_on_shipping_class( $rates, $package )
    {
        if ( is_admin() && ! defined( 'DOING_AJAX' ) )
            return;
    
        // HERE define your shipping class to find
        $class = 602; //insert shipping class ID here
    
        // HERE define the shipping method to hide
        $method_key_id = 'flat_rate:1';
    
        // Checking in cart items
        foreach( WC()->cart->get_cart() as $cart_item ){
            // If we find the shipping class
            if( $cart_item['data']->get_shipping_class_id() == $class ){
                unset($rates[$method_key_id]); // Remove the targeted method
                break; // Stop the loop
            }
        }
        return $rates;
    }
    add_filter( 'woocommerce_package_rates', 'hide_shipping_method_based_on_shipping_class', 10, 2 );
    Thread Starter Rose

    (@thorned-rose)

    I’m marking this as resolved but only from the perspective that I was able to work around a bug with Woocommerce Local Pickup Plus. I am the website maintainer, not the owner so I don’t have access to Woocommerce’s premium plugins support and thus no way of reporting this issue with Local Pickup Plus. At any rate, it’s essentially solved for me now. Hopefully the solution above will be useful for anyone else who wants to disable certain shipping methods for products with a particluar shipping class.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Flat rate appearing despite local pickup being selected’ is closed to new replies.