How can i access current woocommerce order shipping method id?

青春壹個敷衍的年華 提交于 2019-11-29 03:02:51

问题


I have found method

$order->get_shipping_method() 

to access the name, but i want to retrieve the id instead of name?


回答1:


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.




回答2:


$shipping_method = @array_shift($order->get_shipping_methods());
$shipping_method_id = $shipping_method['method_id'];


来源:https://stackoverflow.com/questions/26126438/how-can-i-access-current-woocommerce-order-shipping-method-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!