-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Hi first I would just like to say a big thank you for the perfectly laid out example of this plugin, I tried using wp_list_table but didnt find good examples but yours is very easy to understand.
That being said I do have a problem however I dont think its with the script but rather the data I am passing to it, I installed the plugin to see it and it all works fine, I then copied the plugin main file into my plugin folder renamed it and also the class etc to integrate it into my plugin.
Like your example I am also not using a database for the data but rather I am connecting to the woocommerce API and storing the results into a multi dimensional associative array, however when I give this collected data to the script it is only getting some thing correct.
I have 7 orders that are collected via the API, I then loop over each order and store the data for that order in an associative array, after the for each I add them to the main array then I call that $data.
now when I view the page the correct amount of rows are returned and it even says 7 items in the pagination but the rows are all empty of data, however the data is there as I place a print_r($data); around pre tags and its shows me that $data is populate and in the correct way (i think).
I put the same print_r in the same place on your activated plugin to compare and the structure is the same (see below).
ok time for some show and tell, at the top of the page just under the class I have this
`class Orders_List_Table extends WP_List_Table {
// create our container array
var $MultiArray = array();
`
I make the API call where the example had this line (removed now)
$data = $this->example_data;
when the API returns the data I do a foreach orders as order and setup the array as follows
` foreach($Orders as $Order)
// do some stuff to the returned data and then store what I need in the array below
{
$ThisOrder = array(
'id' => $Order->id,
'customer' => $shipping->first_name.' '.$shipping->last_name,
'qty' => $QTY,
'total' => $Order->currency.' '.$Order->total,
'transaction_id' => $Order->transaction_id,
'status' => $Order->status,
'actions' => 'Actions',
);
// add it to our main array
$MultiArray[] = $ThisOrder;
}`
after the foreach orders I add the following
` $data = $MultiArray;// all 7 orders in this example
echo '<pre>';
print_r($data);// all the orders are in $data
echo '</pre>';`
the print_r shows the following (only showing 3 entries for brevity)
`Array
(
[0] => Array
(
[id] => 5761
[customer] => Jane Blogs
[qty] => 2
[total] => USD 89.98
[transaction_id] => 1248456354654564
[status] => processing
[actions] => Actions
)
[1] => Array
(
[id] => 5728
[customer] => Joe Blogs
[qty] => 1
[total] => USD 49.99
[transaction_id] => 1248456354654564
[status] => processing
[actions] => Actions
)
[2] => Array
(
[id] => 5727
[customer] => Micky Mouse
[qty] => 2
[total] => USD 89.98
[transaction_id] => 1248456354654564
[status] => processing
[actions] => Actions
)
)`
when I do a print_r on the example plugin loaded I get the following (again limited to 3)
`Array
(
[0] => Array
(
[ID] => 8
[title] => 2001
[rating] => G
[director] => Stanley Kubrick
)
[1] => Array
(
[ID] => 1
[title] => 300
[rating] => R
[director] => Zach Snyder
)
[2] => Array
(
[ID] => 2
[title] => Eyes Wide Shut
[rating] => R
[director] => Stanley Kubrick
)
)`
from what I can see they seem to have the same structure (different content obviously) but I can not see anything wrong, also no errors are thrown not even a warning (I have Query Monitor installed).
any ideas where this is going wrong?
thanks in advance for any help
Kind regards
Wayne