![](/img/trans.png)
[英]Trying to save order item meta data with woocommerce_new_order_item hook
[英]WooCommerce woocommerce_new_order_item hook
我在functions.php文件中使用了woocommerce_new_order_item
鈎子。
我的代碼是:
add_action( 'woocommerce_new_order_item', 'wc_order_item_added', 1, 1 );
function wc_order_item_added($item_id, $item, $order_id) {
global $mysqli;
//$order = new WC_Order( $item_id );
$sql = $mysqli->query("INSERT into a_test (one) values ('".$item_id."');");
}
我發現的是: http : //hookr.io/actions/woocommerce_new_order_item/
但是沒有返回$order_id
變量。 唯一$item_id
變量是$item_id
將操作更改為此
add_action( 'woocommerce_new_order_item', 'wc_order_item_added', 1, 3 );
最后一個參數是回調接受的變量數
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.