【发布时间】:2018-08-14 17:24:52
【问题描述】:
我在 Wordpress / Woocommerce 项目的 functions.php 中有一些代码,我尝试根据 USER ID 和 ORDER ID 更新自定义数据库表:
global $wpdb;
$table = $table="wp_thegraffitiwall";
$user = get_current_user_id();
if($user == 0)
exit();
echo "Current User ID is ";
echo $user;
echo "Current Order ID is ";
$wpdb->update($table,$updateStuff,['userid'=>$user]);
// $wpdb->update($table,$updateStuff,['userid'=>$user] AND 'orderid'=>#orderid);
exit("Saved!");
如您所见,我可以检索当前的 USER ID 并使用它,但我无法获取当前的 ORDER ID。
我在 Stackoverflow 上进行了搜索并尝试了以下操作:
$order->get_id();
但这不起作用。
我想将当前的 ORDER ID 分配给 $order_id,然后在我目前已注释掉的更新函数中使用它。
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce orders