Woocommerce Change shipping method title and cost manually

Woocommerce Change shipping method title and cost manually
11Feb, 2020

If we want to change the shipping method title and cost in the checkout of our store based on the shipping class the product has. then this post is helpful. so please follow these below steps:

First of all, we need to add shipping class in our website admin panel of wooCommerce > shipping > Shipping classes
That we are defining in screenshots:

After we create shipping class then we need to define that class in our product. that we defining in the screenshot:

Woocommerce Change shipping method title and cost manually

Finally we need to add a code to our theme’s functions.php file. This code is below.

add_filter( 'woocommerce_package_rates', 'hide_shipping_method_based_on_shipping_class', 10, 2 );
function hide_shipping_method_based_on_shipping_class( $rates, $package )
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
$class_slug = 'free-shipping';
foreach( WC()->cart->get_cart() as $cart_item ){
if( $cart_item['data']->get_shipping_class() == $class_slug ){
foreach( $rates as $rate_key => $rate ){
$rates[$rate_key]->cost = 0;
$rates[$rate_key]->label = __( 'Offerts', 'woocommerce' );
return $rates;


  • AffiliateLabz February 16, 2020 @ 6:59 am

    Great post! Super high-quality! Keep it up! 🙂

  • JamesjaB April 28, 2020 @ 2:12 am

    Thanks, this site is extremely practical.

  • erotik izle November 12, 2020 @ 7:21 pm

    Thanks a lot for the article. Thanks Again. Fantastic. Tarrah Jakob Napoleon

  • erotik November 14, 2020 @ 9:45 pm

    I really like your writing style, superb information, thanks for posting : D. Karlee Constantine Pollie

  • sikis izle November 15, 2020 @ 3:44 pm

    This is my first time go to see at here and i am genuinely happy to read everthing at single place. Laurice Burke Tita

  • sikis izle November 16, 2020 @ 12:20 am

    Hi! I just want to give you a huge thumbs up for your great information you have here on this post. I am returning to your blog for more soon. Fredericka Samuele Schroeder

  • film November 28, 2020 @ 6:10 pm

    Thanks again for the blog article. Thanks Again. Really Cool. Abigail Dorian Charlton

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here :