我需要创建一个向我的插件WooCommerce Dymo Print返回值的函数。它要求$order_id,$label和$object。该$object是场我需要的价值回归。
我创建了以下代码:
add_filter('wc_dymo_order_function', 'wpf_dymo_order_output',10,3);
function wpf_dymo_order_output( $order_id, $label, $object ) {
if($label=='shipping' && $object='DEL_DATE') {
//Get order from order ID
$order=wc_get_order($order_id);
$del_date='';
$order_data = $order->get_data(); // The Order data
$order_del_date = $order_data['delivery_date'];
//Return a list (string) of all product inside this order, make sure it's well formatted before printing.
return $order_del_date;
} else {
//Return order_id if is not correct label and object
return '';
}
}
Run Code Online (Sandbox Code Playgroud)
但是,它似乎不起作用,我认为是因为delivery_date嵌套在数组中,并且我没有正确获取它。 …