0
SELECT * 
FROM `wpet_woocommerce_order_items` a 
LEFT JOIN `wpet_woocommerce_order_itemmeta` b ON a.order_item_id = b.order_item_id 
LEFT JOIN `wpet_users` f ON f.ID = b.meta_value AND b.meta_key = 'seller_id' 
LEFT JOIN `wpet_dokan_orders` c  ON a.order_id = c.order_id 
LEFT JOIN `wpet_posts` d ON a.order_id = d.ID   
WHERE a.order_id = " + value.OrderNum + " AND a.order_item_type = 'line_item';

I am trying to pull various information from woocommerce using an API, essentially, the order item, value, the line total and commissions, I have some data coming in when the API syncs, the API is posting just the order ID (value.OrderNum) which I am using to build the query. here is the woocommerce hook...

function send2VendorAPI( $order_id ){
$order = wc_get_order( $order_id );


$data = array(
    'OrderNum'=>$order->get_id(),
    

);

Then i use this order ID to grab all the information. Thanks for any thoights from the experts on here...

GMB
  • 216,147
  • 25
  • 84
  • 135
noetico
  • 25
  • 6
  • What is the problem with this query? – GMB Aug 12 '20 at 22:46
  • The query looks good (as in the syntax is fine). Without knowing the data and the expected vs actual output, I can't provide more feedback than that. – The James Aug 12 '20 at 23:51
  • Sorry for late reply, now I have verified the query oulls the right data. There is an exception in the application around a null value which is quite confusing, given that binding the result to a gridview shows me the data just fine... the line with `x.Field("order_item_id")` returns null. This is worrying because I get all the data when I bind to a gridview. `DataTable wcOrder_data = new DataTable(); dt.Fill(wcOrder_data); then: var getUniqueItems = wcOrder_data.AsEnumerable().GroupBy(x => x.Field("order_item_id")).Select...` returns null – noetico Aug 13 '20 at 13:17
  • Value cannot be null. Parameter name: value ... this is the error, I don't know where the null reference is. It points to `var getUniqueItems = wcOrder_data.AsEnumerable().GroupBy(x => x.Field("order_item_id"))` for which wcOrder_data binds just fine to a gridview. – noetico Aug 13 '20 at 13:58
  • If it helps, here's the error: ` at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Double.Parse(String s) at App.tester.<>c.b__2_1(IGrouping`2 g) in C:\Users\U\Documents\Visual Studio 2015\Projects\App\tester.aspx.cs:line 43 at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at App.tester.Button1_Click(Object sender, EventArgs e) in C:\Users\U\Documents\Visual Studio 2015\Projects\..\tester.aspx.cs:line 67` Line 43 is what I have posted in the last comment – noetico Aug 13 '20 at 15:06

0 Answers0