• I have some meal packages to sell. For example.
    Chicken meal has variations: 10 pack, 14 pack, 18 pack.
    I want to disable flat_rate:3 when people order 10 pack. But I don’t know how to get the variation.
    My code is below:

    
    function hide_one_delivery( $rates ) {
        global $woocommerce, $product;
        $10_pack = 0;
        foreach ( $woocommerce->cart->cart_contents as $product ) {
            // What to put in this loop??
            $10_pack += 1;
        }
        if ($10_pack > 0){
            unset( $rates['flat_rate:3'] );
        }
        return $rates;
    }
    add_filter( 'woocommerce_package_rates', 'hide_one_delivery', 100 );
    
    

    Thank for help.

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Unset shipping method based on Product variation’ is closed to new replies.