I have found method
$order->get_shipping_method()
to access the name, but i want to retrieve the id instead of name?
Current method: The current way of accomplishing this is by using this function: $order->get_id(); That should return the order id without "#".
Using some WC_Order and WC_Abstract_Order methods (example): // Get an instance of the WC_Order object (same as before) $order = wc_get_order( $order_id ); $order_id = $order->get_id(); // Get the order ID $parent_id = $order->get_parent_id(); // Get the parent order ID (for subscriptions…)
thought i'd share how I solved this if someone runs into the same problem as me. I have WC_Order in the $order variable.
$order->get_items( 'shipping' );
This gives me an array with name, type, method_id, cost and taxes.
$shipping_method = @array_shift($order->get_shipping_methods());
$shipping_method_id = $shipping_method['method_id'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With