Use Select Query to get post id and meta_value from postmeta - woocommerce

1.1k views Asked by At

I am trying to get meta_value from postmeta using SQL select query, but it returns wc_order_h8K0C1ODu2134 instead of meta_value which is Table No 10

   global $wpdb;

   $order_id = $order->get_id();
   $order_num = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = 
   $order_id" ) );

   echo $order_num->post_id;  //which is 274 ok
   echo $order_num->meta_value;  // but meta_value retrun wc_order_h8K0C1ODu2134 and it should be Table No 10

I need to manipulate meta_value at thankyou page, eg. if the admin change Table No 10 to Table No 12 while the user is waiting for the admin response

but without having meta_value, I can't do that.

so how can I get meta_value which is Table No 10 (and not that wc_order_h8K0C1ODu2134)

I have tried different SQL techniques but it always returns wc_order_h8K0C1ODu2134.

Thanks

0

There are 0 answers