• Resolved kare93

    (@kare93)


    Hello woocommerce team,

    My code:

    add_filter(‘woocommerce_package_rates’, ‘hide_non_selected_shipping_methods’, 0);

    function hide_non_selected_shipping_methods($rates) {
    $shipping_method_1 =’free_shipping:4′; // δωρεαν μεταφορικα
    $shipping_method_2 =’flat_rate:5′; // αποστολη σε διευθυνση
    $shipping_method_3 =’flat_rate:6′; // στο σχολειο
    $shipping_method_4 =’local_pickup:7′; // παραλαβη απ το καταστημα
    global $woocommerce;
    $chosen_methods = WC()->session->get( ‘chosen_shipping_methods’ );
    $chosen_shipping = $chosen_methods[0];

    if ($chosen_shipping == $shipping_method_2) {
    echo ‘hello’;
    //echo ‘<label for=”shipping_method_0_free_shipping4″ style=”display:none !important;”>’ ;
    unset( $rates[$shipping_method_1] );
    }
    return $rates;
    }

    What is going wrong and i can’t unset shipping methods?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to display only the shipping method that i have chosen to cart page’ is closed to new replies.