I have some code in the functions.php
of a Wordpress / Woocommerce project, where I try to update a custom database table based on USER ID and 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!");
As you can see I can retrieve the current USER ID and use it, but I am having trouble getting the current ORDER ID.
I have searched on Stackoverflow and tried things like:
$order->get_id();
But this does not work.
I want to assign the current ORDER ID to the $order_id and then use it in the update function further down which I have currently commented out.