Raymond the Developer
Raymond the Developer

Reputation: 1676

How to get shipping class name not slug woocommerce

global $product;
$shippingClass = $product->get_shipping_class();

this returns the slug but I need the name how do I do this?

Upvotes: 1

Views: 1655

Answers (1)

dipmala
dipmala

Reputation: 2011

After $shippingClass add below lines it will get the name.

      $shipp_classname= get_term_by('slug',$shippingClass ,'product_shipping_class');
      echo $shipp_classname->name; 

So complete code is following.

      global $product;
      $shippingClass = $product->get_shipping_class();

      $shipp_classname= get_term_by('slug',$shippingClass ,'product_shipping_class');
      echo $shipp_classname->name; 

Upvotes: 5

Related Questions