Website on wordpress. To print a booked PDF ticket, I use plugins: woocommerce and woocommerce-pdf-invoices-packing-slips. Before printing, in the letter template, I need to add some data from the database table. The plugin has a variable $this->order_id
- it contains the order number.
I tried to make such a query to the database:
global $wpdb;
$wt_order_ids = $wpdb->query($wpdb->prepare("SELECT * FROM {$wpdb->prefix}my_table WHERE order_id = %d", $this->order_id));
As a result, nothing is displayed. But, if the request is edited a little:
$wt_order_ids = $wpdb->query($wpdb->prepare("SELECT * FROM {$wpdb->prefix}my_table WHERE order_id = 777"));
those. instead of $this->order_id, register an order number already in the table, for example 777, then the request works as expected, and I get the data I need.
I thought maybe at the moment when I try to access the database, the actual order number is not yet in the database. Then why can I print $this->order_id using echo or print_r, but cannot use it when accessing the database?
Please help me solve this problem. I really need to use $this->order_id