• 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)
  • laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi there!

    This would require more complex development. I’ll go ahead and leave this thread open for a while in case anyone else wants to chime in, but in the meantime, I can also recommend the following resources for more development-oriented questions:

    – WooCommerce Slack Community: https://woocommerce.com/community-slack/
    – Advanced WooCommerce group on Facebook: https://www.facebook.com/groups/advanced.woocommerce/

    Cheers!

    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Howdy!

    Since this thread has been inactive for a bit, I’m going to go ahead and close it out. Please feel free to open a new one if you have any further questions or concerns!

    As a last note, if you weren’t able to find any customizations help at the above resources, I can also recommend the following paid services: https://woocommerce.com/customizations/

    Cheers!

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.