WooCommerce get Shipping Class of product from either the product id or the order after order is completed

I have been trying to figure out how to get the shipping class from the order after payment is complete. I have found this…

$shipping_class = $cart_item['data']->get_shipping_class();

but that retrieves the shipping class from an active cart, I need to get this after the order is processed, possibly from…

$order = new wc_get_order(id);
$items = $order->get_items();

I can then get the product and variation ids but for some reason I am not seeing how to get the shipping class from this.

any help on this would be greatly appreciated!

1 Answer
1

Palm to FACE!!!

using the product id…

$_product = get_product(id);

$_product = wc_get_product()

$shipclass = $_product->get_shipping_class();

this returns the products shipping class.

EDIT: as mentioned by Aniruddha get_product is depreciated answer has been updated.

Leave a Comment