我在Wordpress / Woocommerce项目的functions.php
中有一些代码,我尝试根据用户ID和订单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!");
如您所见,我可以检索当前用户ID并使用它,但我在获取当前订单ID时遇到了问题。
我已经在Stackoverflow上搜索过了,并尝试了如下内容:
$order->get_id();
但这是行不通的。
我想将当前的订单ID分配给$order_id,然后在更新函数中使用它,我现在已经在下面注释掉了它。
https://stackoverflow.com/questions/51846798
复制相似问题