I have this array, that is dumped from WooCommerce using these lines:
$items = $woocommerce->cart->get_cart();
foreach($items as $item => $values) {
// some code here…
}
If I make a raw output of my cart ($items) I get this:
array(1) {
["f584d8671586d336d84e8cf9ed43303c"]=>
array(11) {
["booking"]=>
array(15) {
["_year"]=>
int(2016)
["_month"]=>
int(8)
["_day"]=>
int(28)
["_persons"]=>
array(1) {
[0]=>
int(1)
}
["_date"]=>
string(9) "2016-8-28"
["date"]=>
string(13) "28 août 2016"
["_time"]=>
string(5) "21:30"
["time"]=>
string(11) "21 h 30 min"
["_qty"]=>
int(1)
["Personnes"]=>
int(1)
["_start_date"]=>
int(1472419800)
["_end_date"]=>
int(1472421600)
["_all_day"]=>
int(0)
["_cost"]=>
int(0)
["_booking_id"]=>
int(13013)
}
["product_id"]=>
int(12856)
["variation_id"]=>
int(0)
["variation"]=>
array(0) {
}
["quantity"]=>
int(1)
["line_total"]=>
float(0)
["line_tax"]=>
int(0)
["line_subtotal"]=>
int(0)
["line_subtotal_tax"]=>
int(0)
["line_tax_data"]=>
array(2) {
["total"]=>
array(0) {
}
["subtotal"]=>
array(0) {
}
}
["data"]=>
object(WC_Product_Booking)#11131 (20) {
["availability_rules":"WC_Product_Booking":private]=>
array(0) {
}
["id"]=>
int(12856)
["post"]=>
object(WP_Post)#11132 (24) {
["ID"]=>
int(12856)
["post_author"]=>
string(2) "14"
["post_date"]=>
string(19) "2016-08-16 22:04:09"
["post_date_gmt"]=>
string(19) "2016-08-16 20:04:09"
["post_content"]=>
string(0) ""
["post_title"]=>
string(10) "La Cuchara"
["post_excerpt"]=>
string(0) ""
["post_status"]=>
string(7) "publish"
["comment_status"]=>
string(4) "open"
["ping_status"]=>
string(6) "closed"
["post_password"]=>
string(0) ""
["post_name"]=>
string(12) "la-cuchara-2"
["to_ping"]=>
string(0) ""
["pinged"]=>
string(0) ""
["post_modified"]=>
string(19) "2016-08-16 22:13:52"
["post_modified_gmt"]=>
string(19) "2016-08-16 20:13:52"
["post_content_filtered"]=>
string(0) ""
["post_parent"]=>
int(0)
["guid"]=>
string(59) ""
["menu_order"]=>
int(0)
["post_type"]=>
string(7) "product"
["post_mime_type"]=>
string(0) ""
["comment_count"]=>
string(1) "0"
["filter"]=>
string(3) "raw"
}
["product_type"]=>
string(7) "booking"
["shipping_class":protected]=>
string(0) ""
["shipping_class_id":protected]=>
int(0)
["total_stock"]=>
NULL
["supports":protected]=>
array(0) {
}
["price"]=>
string(1) "0"
["wc_display_cost"]=>
string(0) ""
["wc_booking_base_cost"]=>
string(0) ""
["wc_booking_min_duration"]=>
string(1) "1"
["wc_booking_cost"]=>
string(0) ""
["wc_booking_has_resources"]=>
string(2) "no"
["wc_booking_has_persons"]=>
string(3) "yes"
["wc_booking_has_person_types"]=>
string(2) "no"
["wc_booking_min_persons_group"]=>
string(1) "1"
["tax_status"]=>
string(7) "taxable"
["stock_status"]=>
string(7) "instock"
["manage_stock"]=>
string(2) "no"
}
}
}
I would like to use specific data values in php variables (the booking date, the time and the person):
["date"]=> string(13) "28 août 2016"
["_persons"]=> array(1) { [0]=> int(1) }
["time"]=> string(11) "21 h 30 min"
How can I do to get this specific values from WooCommerce cart object?
Thanks
You could try first this (but I am unsure as I think it can be an object, so may be it will not work):
echo $items[0]['booking']['date'] . '<br>';
echo $items[0]['booking']['_persons'] . '<br>';
echo $items[0]['booking']['time'] . '<br>';
If not working with a foreach loop it will:
$items = WC()->cart->get_cart();
foreach($items as $item) {
$date = $item['booking']['date'];
$person = $item['booking']['_persons'];
$time = $item['booking']['time'];
}
// displaying values for test
echo 'Booking - Date: ' . $date . '/ Person: ' . $person . '/ Time: ' . $time;
One of these will work, for sure…
Related
I want to save the order status history for all orders on woocommerce. e.g If the order status is changed from pending to processing the previous status along with its timestamp should be saved so that user can view their order status history through this page. I have done some research but I couldn't find a way to do this.
I would like to hear the suggestions. The order tracking is done using a custom plugin. I am retrieving the order details using the following $order object
$order = wc_get_order( $order_id );
I am retrieving the billing, shipping details, status and products details using this object. It would be somewhat easier for me to maintain and get the order status history using this object. Following is the object data I get from the above method
object(WC_Order)#3738 (14) { ["status_transition":protected]=> bool(false) ["data":protected]=> array(28) { ["parent_id"]=> int(0) ["status"]=> string(10) "processing" ["currency"]=> string(3) "GBP" ["version"]=> string(5) "3.5.0" ["prices_include_tax"]=> bool(false) ["date_created"]=> object(WC_DateTime)#3745 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2018-11-01 15:05:40.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } ["date_modified"]=> object(WC_DateTime)#3742 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2018-11-01 16:02:14.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } ["discount_total"]=> string(2) "36" ["discount_tax"]=> string(1) "0" ["shipping_total"]=> string(1) "0" ["shipping_tax"]=> string(1) "0" ["cart_tax"]=> string(1) "0" ["total"]=> string(6) "325.30" ["total_tax"]=> string(1) "0" ["customer_id"]=> int(0) ["order_key"]=> string(22) "wc_order_5bdb16e89ce36" ["billing"]=> array(11) { ["first_name"]=> string(6) "Faizan" ["last_name"]=> string(5) "Zahid" ["company"]=> string(4) "Home" ["address_1"]=> string(6) "456789" ["address_2"]=> string(4) "5678" ["city"]=> string(6) "lahore" ["state"]=> string(2) "PB" ["postcode"]=> string(6) "456789" ["country"]=> string(2) "PK" ["email"]=> string(19) "fzahid001#gmail.com" ["phone"]=> string(0) "" } ["shipping"]=> array(9) { ["first_name"]=> string(6) "Tabish" ["last_name"]=> string(5) "Munir" ["company"]=> string(7) "Frizhub" ["address_1"]=> string(8) "34567890" ["address_2"]=> string(7) "4567890" ["city"]=> string(6) "lahore" ["state"]=> string(2) "PB" ["postcode"]=> string(6) "456789" ["country"]=> string(2) "PK" } ["payment_method"]=> string(5) "other" ["payment_method_title"]=> string(5) "other" ["transaction_id"]=> string(0) "" ["customer_ip_address"]=> string(0) "" ["customer_user_agent"]=> string(0) "" ["created_via"]=> string(5) "admin" ["customer_note"]=> string(0) "" ["date_completed"]=> NULL ["date_paid"]=> object(WC_DateTime)#3790 (4) { ["utc_offset":protected]=> int(0) ["date"]=> string(26) "2018-11-01 15:15:33.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } ["cart_hash"]=> string(0) "" } ["items":protected]=> array(0) { } ["items_to_delete":protected]=> array(0) { } ["cache_group":protected]=> string(6) "orders" ["data_store_name":protected]=> string(5) "order" ["object_type":protected]=> string(5) "order" ["id":protected]=> int(983) ["changes":protected]=> array(0) { } ["object_read":protected]=> bool(true) ["extra_data":protected]=> array(0) { } ["default_data":protected]=> array(28) { ["parent_id"]=> int(0) ["status"]=> string(0) "" ["currency"]=> string(0) "" ["version"]=> string(0) "" ["prices_include_tax"]=> bool(false) ["date_created"]=> NULL ["date_modified"]=> NULL ["discount_total"]=> int(0) ["discount_tax"]=> int(0) ["shipping_total"]=> int(0) ["shipping_tax"]=> int(0) ["cart_tax"]=> int(0) ["total"]=> int(0) ["total_tax"]=> int(0) ["customer_id"]=> int(0) ["order_key"]=> string(0) "" ["billing"]=> array(11) { ["first_name"]=> string(0) "" ["last_name"]=> string(0) "" ["company"]=> string(0) "" ["address_1"]=> string(0) "" ["address_2"]=> string(0) "" ["city"]=> string(0) "" ["state"]=> string(0) "" ["postcode"]=> string(0) "" ["country"]=> string(0) "" ["email"]=> string(0) "" ["phone"]=> string(0) "" } ["shipping"]=> array(9) { ["first_name"]=> string(0) "" ["last_name"]=> string(0) "" ["company"]=> string(0) "" ["address_1"]=> string(0) "" ["address_2"]=> string(0) "" ["city"]=> string(0) "" ["state"]=> string(0) "" ["postcode"]=> string(0) "" ["country"]=> string(0) "" } ["payment_method"]=> string(0) "" ["payment_method_title"]=> string(0) "" ["transaction_id"]=> string(0) "" ["customer_ip_address"]=> string(0) "" ["customer_user_agent"]=> string(0) "" ["created_via"]=> string(0) "" ["customer_note"]=> string(0) "" ["date_completed"]=> NULL ["date_paid"]=> NULL ["cart_hash"]=> string(0) "" } ["data_store":protected]=> object(WC_Data_Store)#3734 (4) { ["instance":"WC_Data_Store":private]=> object(WC_Order_Data_Store_CPT)#3804 (3) { ["internal_meta_keys":protected]=> array(78) { [0]=> string(10) "_parent_id" [1]=> string(7) "_status" [2]=> string(9) "_currency" [3]=> string(8) "_version" [4]=> string(19) "_prices_include_tax" [5]=> string(13) "_date_created" [6]=> string(14) "_date_modified" [7]=> string(15) "_discount_total" [8]=> string(13) "_discount_tax" [9]=> string(15) "_shipping_total" [10]=> string(13) "_shipping_tax" [11]=> string(9) "_cart_tax" [12]=> string(6) "_total" [13]=> string(10) "_total_tax" [14]=> string(12) "_customer_id" [15]=> string(10) "_order_key" [16]=> string(8) "_billing" [17]=> string(9) "_shipping" [18]=> string(15) "_payment_method" [19]=> string(21) "_payment_method_title" [20]=> string(15) "_transaction_id" [21]=> string(20) "_customer_ip_address" [22]=> string(20) "_customer_user_agent" [23]=> string(12) "_created_via" [24]=> string(14) "_customer_note" [25]=> string(15) "_date_completed" [26]=> string(10) "_date_paid" [27]=> string(10) "_cart_hash" [28]=> string(14) "_customer_user" [29]=> string(10) "_order_key" [30]=> string(15) "_order_currency" [31]=> string(19) "_billing_first_name" [32]=> string(18) "_billing_last_name" [33]=> string(16) "_billing_company" [34]=> string(18) "_billing_address_1" [35]=> string(18) "_billing_address_2" [36]=> string(13) "_billing_city" [37]=> string(14) "_billing_state" [38]=> string(17) "_billing_postcode" [39]=> string(16) "_billing_country" [40]=> string(14) "_billing_email" [41]=> string(14) "_billing_phone" [42]=> string(20) "_shipping_first_name" [43]=> string(19) "_shipping_last_name" [44]=> string(17) "_shipping_company" [45]=> string(19) "_shipping_address_1" [46]=> string(19) "_shipping_address_2" [47]=> string(14) "_shipping_city" [48]=> string(15) "_shipping_state" [49]=> string(18) "_shipping_postcode" [50]=> string(17) "_shipping_country" [51]=> string(15) "_completed_date" [52]=> string(10) "_paid_date" [53]=> string(10) "_edit_lock" [54]=> string(10) "_edit_last" [55]=> string(14) "_cart_discount" [56]=> string(18) "_cart_discount_tax" [57]=> string(15) "_order_shipping" [58]=> string(19) "_order_shipping_tax" [59]=> string(10) "_order_tax" [60]=> string(12) "_order_total" [61]=> string(15) "_payment_method" [62]=> string(21) "_payment_method_title" [63]=> string(15) "_transaction_id" [64]=> string(20) "_customer_ip_address" [65]=> string(20) "_customer_user_agent" [66]=> string(12) "_created_via" [67]=> string(14) "_order_version" [68]=> string(19) "_prices_include_tax" [69]=> string(15) "_date_completed" [70]=> string(10) "_date_paid" [71]=> string(15) "_payment_tokens" [72]=> string(22) "_billing_address_index" [73]=> string(23) "_shipping_address_index" [74]=> string(15) "_recorded_sales" [75]=> string(29) "_recorded_coupon_usage_counts" [76]=> string(29) "_download_permissions_granted" [77]=> string(20) "_order_stock_reduced" } ["meta_type":protected]=> string(4) "post" ["object_id_field_for_meta":protected]=> string(0) "" } ["stores":"WC_Data_Store":private]=> array(20) { ["coupon"]=> string(24) "WC_Coupon_Data_Store_CPT" ["customer"]=> string(22) "WC_Customer_Data_Store" ["customer-download"]=> string(31) "WC_Customer_Download_Data_Store" ["customer-download-log"]=> string(35) "WC_Customer_Download_Log_Data_Store" ["customer-session"]=> string(30) "WC_Customer_Data_Store_Session" ["order"]=> string(23) "WC_Order_Data_Store_CPT" ["order-refund"]=> string(30) "WC_Order_Refund_Data_Store_CPT" ["order-item"]=> string(24) "WC_Order_Item_Data_Store" ["order-item-coupon"]=> string(31) "WC_Order_Item_Coupon_Data_Store" ["order-item-fee"]=> string(28) "WC_Order_Item_Fee_Data_Store" ["order-item-product"]=> string(32) "WC_Order_Item_Product_Data_Store" ["order-item-shipping"]=> string(33) "WC_Order_Item_Shipping_Data_Store" ["order-item-tax"]=> string(28) "WC_Order_Item_Tax_Data_Store" ["payment-token"]=> string(27) "WC_Payment_Token_Data_Store" ["product"]=> string(25) "WC_Product_Data_Store_CPT" ["product-grouped"]=> string(33) "WC_Product_Grouped_Data_Store_CPT" ["product-variable"]=> string(34) "WC_Product_Variable_Data_Store_CPT" ["product-variation"]=> string(35) "WC_Product_Variation_Data_Store_CPT" ["shipping-zone"]=> string(27) "WC_Shipping_Zone_Data_Store" ["webhook"]=> string(21) "WC_Webhook_Data_Store" } ["current_class_name":"WC_Data_Store":private]=> string(23) "WC_Order_Data_Store_CPT" ["object_type":"WC_Data_Store":private]=> string(5) "order" } ["meta_data":protected]=> array(5) { [0]=> object(WC_Meta_Data)#3792 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(2671) ["key"]=> string(17) "_vc_post_settings" ["value"]=> array(1) { ["vc_grid_id"]=> array(0) { } } } ["data":protected]=> array(3) { ["id"]=> int(2671) ["key"]=> string(17) "_vc_post_settings" ["value"]=> array(1) { ["vc_grid_id"]=> array(0) { } } } } [1]=> object(WC_Meta_Data)#3793 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(2718) ["key"]=> string(14) "slide_template" ["value"]=> string(7) "default" } ["data":protected]=> array(3) { ["id"]=> int(2718) ["key"]=> string(14) "slide_template" ["value"]=> string(7) "default" } } [2]=> object(WC_Meta_Data)#3795 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(2719) ["key"]=> string(19) "_bewpi_invoice_date" ["value"]=> string(19) "2018-11-01 15:08:31" } ["data":protected]=> array(3) { ["id"]=> int(2719) ["key"]=> string(19) "_bewpi_invoice_date" ["value"]=> string(19) "2018-11-01 15:08:31" } } [3]=> object(WC_Meta_Data)#3794 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(2720) ["key"]=> string(21) "_bewpi_invoice_number" ["value"]=> string(3) "983" } ["data":protected]=> array(3) { ["id"]=> int(2720) ["key"]=> string(21) "_bewpi_invoice_number" ["value"]=> string(3) "983" } } [4]=> object(WC_Meta_Data)#3797 (2) { ["current_data":protected]=> array(3) { ["id"]=> int(2721) ["key"]=> string(23) "_bewpi_invoice_pdf_path" ["value"]=> string(19) "2018/00983-2018.pdf" } ["data":protected]=> array(3) { ["id"]=> int(2721) ["key"]=> string(23) "_bewpi_invoice_pdf_path" ["value"]=> string(19) "2018/00983-2018.pdf" } } } }
You can use a custom field to keep the order status history. Then you will use the following hooked functions that will:
start registering pending status on order creation once the order has been placed by customer,
update the history each time the status change.
The code:
// Initiating the history process registering pending status on order creation
add_action( 'woocommerce_checkout_create_order', 'init_order_status_history', 20, 4 );
function init_order_status_history( $order, $data ){
// Set the default time zone (http://php.net/manual/en/timezones.php)
date_default_timezone_set('Europe/Paris');
// Init order status history on order creation.
$order->update_meta_data( '_status_history', array( time() => 'pending' ) );
}
// Getting each status change history and saving the data
add_action( 'woocommerce_order_status_changed', 'order_status_history', 20, 4 );
function order_status_history( $order_id, $old_status, $new_status, $order ){
// Set the default time zone (http://php.net/manual/en/timezones.php)
date_default_timezone_set('Europe/Paris');
// Get order status history
$order_status_history = $order->get_meta( '_status_history' ) ? $order->get_meta( '_status_history' ) : array();
// Add the current timestamp with the new order status to the history array
$order_status_history[time()] = $new_status;
// Update the order status history (as order meta data)
$order->update_meta_data( '_status_history', $order_status_history );
$order->save(); // Save
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
The following shortcode will output the different order statuses and timestamps:
add_shortcode( 'status_history', 'get_order_status_history' );
function get_order_status_history(){
// Get an instance of the WC_Order object from the order ID
$order = wc_get_order( $order_id );
// Get the history data
$status_history = $order->get_meta('_status_history');
$output = '<div class="order-statuses-container">';
// Loop through the statuses (and timestamps)
foreach( $status_history as $timestamp => $order_status ){
output .= '<div class="status-step">' . ucfirst( $order_status ) . '<br>
<span class="date-time">' . date('Y-m-d H:i:s', $timestamp ) . '</span></div>';
}
return $output . '</div>';
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
You still need:
to set the correct date format (easy to set using the date() documentation)
to set the correct time zone in both first functions
to set the correct html structure output in the shortcode function.
to style as desired adding some CSS rules to your theme's styles.css file
USAGE:
1) In the Wordpress text editor of a post or a page: [status_history]
2) In PHP code: echo do_shortcode( "[status_history]" );
I have an array with products (each product has more arrays)
I want to get the values ["0_1"] or ["0_2"]?
If it starts with 0 it should send that product to the end of the array
array(14) {
["0_1"]=> array(27) {
["files"]=> array(0) { }
["images"]=> array(0) { }
["form_addtocart"]=> string(0) ""
["has_addtocart"]=> bool(false)
["product_flypage"]=> string(137) "index.php?page=shop.product_details&flypage=flypage.tpl&product_id=3299&category_id=88&option=com_virtuemart&Itemid=2"
["product_thumb_image"]=> string(170) "http://www.e-theodoulidis.gr/components/com_virtuemart/show_image_in_imgtag.php?filename=General_Electric_4e5f4d8265044.jpg&newxsize=120&newysize=120&fileout="
["product_full_image"]=> string(108) "http://www.e-theodoulidis.gr/components/com_virtuemart/shop_image/product/General_Electric_4e5f4d8265044.jpg"
["full_image_width"]=> int(1064)
["full_image_height"]=> int(1064)
["product_name"]=> string(42) "General Electric Τηλέγωνο CE 30044"
["product_s_desc"]=> string(0) ""
["product_details"]=> string(43) "Λεπτομέρειες προϊόντος"
["product_rating"]=> string(0) ""
["product_price"]=> string(344) " Καλέστε για Τιμή "
["product_price_raw"]=> array(1) {
["product_price"]=> float(0)
}
["product_sku"]=> string(25) "General Electric CE 30044"
["product_weight"]=> string(6) "0.0000"
["product_weight_uom"]=> string(2) "kg"
["product_length"]=> string(6) "0.0000"
["product_width"]=> string(6) "0.0000"
["product_height"]=> string(6) "0.0000"
["product_lwh_uom"]=> string(6) "inches"
["product_in_stock"]=> string(1) "0"
["product_availability_date"]=> NULL
["product_availability"]=> string(0) ""
["cdate"]=> string(10) "1314868610"
["mdate"]=> string(10) "1314868610"
}
["0_2"]=> array(27) {
["files"]=> array(0) { }
["images"]=> array(0) { }
["form_addtocart"]=> string(0) ""
["has_addtocart"]=> bool(false)
["product_flypage"]=> string(137) "index.php?page=shop.product_details&flypage=flypage.tpl&product_id=7609&category_id=88&option=com_virtuemart&Itemid=2"
["product_thumb_image"]=> string(188) "http://www.e-theodoulidis.gr/components/com_virtuemart/show_image_in_imgtag.php?filename=resized%2FPanasonic________533a7b4f573b0_120x120.jpg&newxsize=120&newysize=120&fileout="
["product_full_image"]=> string(108) "http://www.e-theodoulidis.gr/components/com_virtuemart/shop_image/product/Panasonic________533a7b4f5cba6.jpg"
["full_image_width"]=> int(530)
["full_image_height"]=> int(403)
["product_name"]=> string(39) "Panasonic Τηλέφωνο KX-TS560EX2B"
["product_s_desc"]=> string(0) ""
["product_details"]=> string(43) "Λεπτομέρειες προϊόντος"
["product_rating"]=> string(0) ""
["product_price"]=> string(339) " Καλέστε για Τιμή "
["product_price_raw"]=> array(1) {
["product_price"]=> float(0)
}
["product_sku"]=> string(22) "Panasonic KX-TS560EX2B"
["product_weight"]=> string(6) "0.0000"
["product_weight_uom"]=> string(2) "kg"
["product_length"]=> string(6) "0.0000"
["product_width"]=> string(6) "0.0000"
["product_height"]=> string(6) "0.0000"
["product_lwh_uom"]=> string(6) "inches"
["product_in_stock"]=> string(1) "0"
["product_availability_date"]=> NULL
["product_availability"]=> string(0) ""
["cdate"]=> string(10) "1396341583"
["mdate"]=> string(10) "1426577025"
}
}
Those on the left (eg. "0_1") are the array keys, and the values are the ones on the right.
To get just the keys, use:
$arrayOfKeys = array_keys($array)
or to iterate over each item, use:
foreach ($array as $key => $value) { }
I am trying to get some value from the massive array, and there occured some problem.
I have such array:
array(2) {
[0]=>
array(23) {
["ITEM_ID"]=>
int(2331)
["ITEM_TYPE_ID"]=>
string(1) "1"
["CART_ITEM_ID"]=>
string(0) ""
["SAVED_TYPE_ID"]=>
string(0) ""
["ITEM_NAME"]=>
string(17) "TEST STOCK LEVELS"
["ERROR"]=>
string(0) ""
["PROPERTIES"]=>
array(1) {
[522]=>
array(1) {
[0]=>
string(4) "1122"
}
}
["PROPERTIES_INFO"]=>
array(1) {
[522]=>
array(12) {
["USAGE_TYPE"]=>
string(1) "1"
["CONTROL"]=>
string(7) "LISTBOX"
["TYPE"]=>
string(1) "1"
["NAME"]=>
string(11) "TEST OPTION"
["VALUES"]=>
array(1) {
[0]=>
string(4) "1122"
}
["REQUIRED"]=>
string(1) "1"
["PARENT_PROPERTY_ID"]=>
string(0) ""
["PARENT_VALUE_ID"]=>
string(0) ""
["TEXT"]=>
array(0) {
}
["CONTROL_PRICE"]=>
int(0)
["ORDER"]=>
string(1) "1"
["QUANTITY_ACTION"]=>
string(1) "1"
}
}
["PROPERTIES_PRICE"]=>
float(10)
["PROPERTIES_PERCENTAGE"]=>
int(0)
["PROPERTIES_BUYING"]=>
int(0)
["PROPERTIES_DISCOUNT"]=>
int(0)
["PROPERTIES_MORE"]=>
string(1) "0"
["COMPONENTS"]=>
array(0) {
}
["QUANTITY"]=>
int(11)
["TAX_FREE"]=>
string(1) "0"
["DISCOUNT"]=>
int(1)
["BUYING_PRICE"]=>
string(0) ""
["PRICE_EDIT"]=>
string(1) "0"
["PRICE"]=>
string(5) "10.00"
["CHECK_PRICE"]=>
float(20)
["MAX_ITEM_DISCOUNT"]=>
float(20)
["CART_PRICE"]=>
float(20)
}
[1]=>
array(23) {
["ITEM_ID"]=>
int(2331)
["ITEM_TYPE_ID"]=>
string(1) "1"
["CART_ITEM_ID"]=>
string(0) ""
["SAVED_TYPE_ID"]=>
string(0) ""
["ITEM_NAME"]=>
string(17) "TEST STOCK LEVELS"
["ERROR"]=>
string(0) ""
["PROPERTIES"]=>
array(1) {
[522]=>
array(1) {
[0]=>
string(4) "1123"
}
}
["PROPERTIES_INFO"]=>
array(1) {
[522]=>
array(12) {
["USAGE_TYPE"]=>
string(1) "1"
["CONTROL"]=>
string(7) "LISTBOX"
["TYPE"]=>
string(1) "1"
["NAME"]=>
string(11) "TEST OPTION"
["VALUES"]=>
array(1) {
[0]=>
string(4) "1123"
}
["REQUIRED"]=>
string(1) "1"
["PARENT_PROPERTY_ID"]=>
string(0) ""
["PARENT_VALUE_ID"]=>
string(0) ""
["TEXT"]=>
array(0) {
}
["CONTROL_PRICE"]=>
int(0)
["ORDER"]=>
string(1) "1"
["QUANTITY_ACTION"]=>
string(1) "1"
}
}
["PROPERTIES_PRICE"]=>
float(20)
["PROPERTIES_PERCENTAGE"]=>
int(0)
["PROPERTIES_BUYING"]=>
int(0)
["PROPERTIES_DISCOUNT"]=>
int(0)
["PROPERTIES_MORE"]=>
string(1) "0"
["COMPONENTS"]=>
array(0) {
}
["QUANTITY"]=>
int(5)
["TAX_FREE"]=>
string(1) "0"
["DISCOUNT"]=>
int(1)
["BUYING_PRICE"]=>
string(0) ""
["PRICE_EDIT"]=>
string(1) "0"
["PRICE"]=>
string(5) "10.00"
["CHECK_PRICE"]=>
float(30)
["MAX_ITEM_DISCOUNT"]=>
float(30)
["CART_PRICE"]=>
float(30)
}
}
Before looping this array, I receive some property_id (1123 for example).
I need to check if this property_id matches this element (1122 in my case)
["PROPERTIES"]=>
array(1) {
[522]=>
array(1) {
[0]=>
string(4) "1122"
}
}
then select its quantity property (in my case it is this element)
["QUANTITY"]=>
int(11)
The problem is to identify from which arrays select this property, because first I need to compare my received value with existing in array(1122 in my case).
I think you could do it faster with a better organized array. As it is I'll do a loop.
Something like that :
$quantity = 0;
$which_array = -1;
foreach($massive as $key=>$value){
if(isset($value['PROPERTIES_INFO'])){
$copy_properties = $value['PROPERTIES_INFO'];
$property_first = reset($copy_properties);
$id_property = key($property_first);
if($id_property == $what_id_you_are_looking_for){
$quantity = $value['QUANTITY'];//delete one of this
//or I don't know wich quantity you want so I put them both
$quantity = $value['PROPERTIES_INFO'][$id_property ]['QUANTITY_ACTION'];//delete one of this
$which_array = $key;
break;
}
}
}
I' am working with WordPress. When I do a normal query everything works great, but when I want to test if theirs no results it should show up something like
"Sorry, but nothing matched your search criteria. Please try again with some different keywords."
This was looking strange to me because even though the query doesn't have any results it still showing as $count 1 whereas it should showup as $count 0. Here is the Code in placed.
URL Variables
$get_search = trim($get_search);
$get_from = trim($get_from);
$get_to = trim($get_to);
$get_districts = trim($get_districts);
$get_string = trim($get_string);
if($get_search == "Submit"){
}
}
?>
This is actually code
<?php
// Get districts from database plugin
$districts = get_district();
$options="";
foreach($districts[0]['choices'] as $key => $val){
if($key == $get_districts){
$options .= "<option value='".$key."' selected>".$val."</option>";
} else {
$options .= "<option value='".$key."'>".$val."</option>";
}
}
?>
<form method="get" action="<?php echo site_url();?>/planned-outages/" enctype="multipart/form-data">
From Date : <input type="text" name="from" class="from" value="<?php echo $get_from; ?>"/>
To Date : <input type="text" name="to" class="to" value="<?php echo $get_to; ?>"/>
District: <select name="districts"><?php echo $options; ?></select>
Search for : <input type="text" name="string" value="<?php echo $get_string; ?>"/>
<input name="search" type="submit"/>
</form>
<?php
global $post;
$args = array(
'order' => 'DESC',
'orderby' => 'post_date',
'post_status' => 'publish',
'post_type' => 'outages',
's' => $get_string,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'district',
'value' => $get_districts,
'compare' => 'LIKE'
),
array(
'key' => 'from_date_time',
'value' => $get_from,
'compare' => 'LIKE'
),
array(
'key' => 'to_date_time',
'value' => $get_to,
'compare' => 'LIKE'
)
)
);
?>
<?php
$list_of_posts = new WP_Query($args);
$count = count($list_of_posts);
if($count > 0){
while ($list_of_posts->have_posts()):$list_of_posts->the_post();
$meta = get_post_meta( get_the_ID(), '');
?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php
endwhile;
} else {
?>
Sorry, but nothing matched your search criteria. Please try again with some different keywords.
<?php
}
?>
When I var_dump($list_of_posts) $list_of_posts this is what I get
object(WP_Query)#443 (46) { ["query"]=> array(6) { ["order"]=> string(4) "DESC" ["orderby"]=> string(9) "post_date" ["post_status"]=> string(7) "publish" ["post_type"]=> string(7) "outages" ["s"]=> string(5) "links" ["meta_query"]=> array(4) { ["relation"]=> string(2) "OR" [0]=> array(3) { ["key"]=> string(8) "district" ["value"]=> string(8) "rakiraki" ["compare"]=> string(4) "LIKE" } [1]=> array(3) { ["key"]=> string(14) "from_date_time" ["value"]=> string(10) "12/26/2013" ["compare"]=> string(4) "LIKE" } [2]=> array(3) { ["key"]=> string(12) "to_date_time" ["value"]=> string(0) "" ["compare"]=> string(4) "LIKE" } } } ["query_vars"]=> array(67) { ["order"]=> string(4) "DESC" ["orderby"]=> string(9) "post_date" ["post_status"]=> string(7) "publish" ["post_type"]=> string(7) "outages" ["s"]=> string(5) "links" ["meta_query"]=> array(4) { ["relation"]=> string(2) "OR" [0]=> array(3) { ["key"]=> string(8) "district" ["value"]=> string(8) "rakiraki" ["compare"]=> string(4) "LIKE" } [1]=> array(3) { ["key"]=> string(14) "from_date_time" ["value"]=> string(10) "12/26/2013" ["compare"]=> string(4) "LIKE" } [2]=> array(3) { ["key"]=> string(12) "to_date_time" ["value"]=> string(0) "" ["compare"]=> string(4) "LIKE" } } ["error"]=> string(0) "" ["m"]=> string(0) "" ["p"]=> int(0) ["post_parent"]=> string(0) "" ["subpost"]=> string(0) "" ["subpost_id"]=> string(0) "" ["attachment"]=> string(0) "" ["attachment_id"]=> int(0) ["name"]=> string(0) "" ["static"]=> string(0) "" ["pagename"]=> string(0) "" ["page_id"]=> int(0) ["second"]=> string(0) "" ["minute"]=> string(0) "" ["hour"]=> string(0) "" ["day"]=> int(0) ["monthnum"]=> int(0) ["year"]=> int(0) ["w"]=> int(0) ["category_name"]=> string(0) "" ["tag"]=> string(0) "" ["cat"]=> string(0) "" ["tag_id"]=> string(0) "" ["author"]=> string(0) "" ["author_name"]=> string(0) "" ["feed"]=> string(0) "" ["tb"]=> string(0) "" ["paged"]=> int(0) ["comments_popup"]=> string(0) "" ["meta_key"]=> string(0) "" ["meta_value"]=> string(0) "" ["preview"]=> string(0) "" ["sentence"]=> string(0) "" ["fields"]=> string(0) "" ["menu_order"]=> string(0) "" ["category__in"]=> array(0) { } ["category__not_in"]=> array(0) { } ["category__and"]=> array(0) { } ["post__in"]=> array(0) { } ["post__not_in"]=> array(0) { } ["tag__in"]=> array(0) { } ["tag__not_in"]=> array(0) { } ["tag__and"]=> array(0) { } ["tag_slug__in"]=> array(0) { } ["tag_slug__and"]=> array(0) { } ["post_parent__in"]=> array(0) { } ["post_parent__not_in"]=> array(0) { } ["author__in"]=> array(0) { } ["author__not_in"]=> array(0) { } ["ignore_sticky_posts"]=> bool(false) ["suppress_filters"]=> bool(false) ["cache_results"]=> bool(true) ["update_post_term_cache"]=> bool(true) ["update_post_meta_cache"]=> bool(true) ["posts_per_page"]=> int(10) ["nopaging"]=> bool(false) ["comments_per_page"]=> string(2) "50" ["no_found_rows"]=> bool(false) ["search_terms_count"]=> int(1) ["search_terms"]=> array(1) { [0]=> string(5) "links" } ["search_orderby_title"]=> array(1) { [0]=> string(35) "fea_posts.post_title LIKE '%links%'" } } ["tax_query"]=> object(WP_Tax_Query)#446 (2) { ["queries"]=> array(0) { } ["relation"]=> string(3) "AND" } ["meta_query"]=> object(WP_Meta_Query)#445 (2) { ["queries"]=> array(3) { [0]=> array(3) { ["key"]=> string(8) "district" ["value"]=> string(8) "rakiraki" ["compare"]=> string(4) "LIKE" } [1]=> array(3) { ["key"]=> string(14) "from_date_time" ["value"]=> string(10) "12/26/2013" ["compare"]=> string(4) "LIKE" } [2]=> array(3) { ["key"]=> string(12) "to_date_time" ["value"]=> string(0) "" ["compare"]=> string(4) "LIKE" } } ["relation"]=> string(2) "OR" } ["date_query"]=> bool(false) ["request"]=> string(767) "SELECT SQL_CALC_FOUND_ROWS fea_posts.ID FROM fea_posts INNER JOIN fea_postmeta ON (fea_posts.ID = fea_postmeta.post_id) INNER JOIN fea_postmeta AS mt1 ON (fea_posts.ID = mt1.post_id) INNER JOIN fea_postmeta AS mt2 ON (fea_posts.ID = mt2.post_id) WHERE 1=1 AND (((fea_posts.post_title LIKE '%links%') OR (fea_posts.post_content LIKE '%links%'))) AND fea_posts.post_type = 'outages' AND (fea_posts.post_status = 'publish') AND ( (fea_postmeta.meta_key = 'district' AND CAST(fea_postmeta.meta_value AS CHAR) LIKE '%rakiraki%') OR (mt1.meta_key = 'from_date_time' AND CAST(mt1.meta_value AS CHAR) LIKE '%12/26/2013%') OR (mt2.meta_key = 'to_date_time' AND CAST(mt2.meta_value AS CHAR) LIKE '%%') ) GROUP BY fea_posts.ID ORDER BY fea_posts.post_date DESC LIMIT 0, 10" ["posts"]=> array(0) { } ["post_count"]=> int(0) ["current_post"]=> int(-1) ["in_the_loop"]=> bool(false) ["comment_count"]=> int(0) ["current_comment"]=> int(-1) ["found_posts"]=> int(0) ["max_num_pages"]=> int(0) ["max_num_comment_pages"]=> int(0) ["is_single"]=> bool(false) ["is_preview"]=> bool(false) ["is_page"]=> bool(false) ["is_archive"]=> bool(false) ["is_date"]=> bool(false) ["is_year"]=> bool(false) ["is_month"]=> bool(false) ["is_day"]=> bool(false) ["is_time"]=> bool(false) ["is_author"]=> bool(false) ["is_category"]=> bool(false) ["is_tag"]=> bool(false) ["is_tax"]=> bool(false) ["is_search"]=> bool(true) ["is_feed"]=> bool(false) ["is_comment_feed"]=> bool(false) ["is_trackback"]=> bool(false) ["is_home"]=> bool(false) ["is_404"]=> bool(false) ["is_comments_popup"]=> bool(false) ["is_paged"]=> bool(false) ["is_admin"]=> bool(false) ["is_attachment"]=> bool(false) ["is_singular"]=> bool(false) ["is_robots"]=> bool(false) ["is_posts_page"]=> bool(false) ["is_post_type_archive"]=> bool(false) ["query_vars_hash"]=> string(32) "53d948b3d27e923c345546711f9b2d03" ["query_vars_changed"]=> bool(false) ["thumbnails_cached"]=> bool(false) ["stopwords":"WP_Query":private]=> array(29) { [0]=> string(5) "about" [1]=> string(2) "an" [2]=> string(3) "are" [3]=> string(2) "as" [4]=> string(2) "at" [5]=> string(2) "be" [6]=> string(2) "by" [7]=> string(3) "com" [8]=> string(3) "for" [9]=> string(4) "from" [10]=> string(3) "how" [11]=> string(2) "in" [12]=> string(2) "is" [13]=> string(2) "it" [14]=> string(2) "of" [15]=> string(2) "on" [16]=> string(2) "or" [17]=> string(4) "that" [18]=> string(3) "the" [19]=> string(4) "this" [20]=> string(2) "to" [21]=> string(3) "was" [22]=> string(4) "what" [23]=> string(4) "when" [24]=> string(5) "where" [25]=> string(3) "who" [26]=> string(4) "will" [27]=> string(4) "with" [28]=> string(3) "www" } }
new WP_Query($args) is just an Object, now an array, so count(object) will always 1.
Just quote from the WP document:
$the_query = new WP_Query ( $args );
// The Loop
if ($the_query->have_posts ())
{
.....
}
else
{
// no posts found
}
http://codex.wordpress.org/Class_Reference/WP_Query
Also, you can use $the_query->found_posts to get the total number.
I have retrieve a view programmaticly in my module with PHP. How can retrieve the values of this view? I'm using drupal 6.
That's the view result in my PHP code:
enter code hereobject(view)#48 (22) {
["db_table"]=>
string(10) "views_view"
["base_table"]=>
string(4) "node"
["args"]=>
array(0) {
}
["use_ajax"]=>
bool(false)
["result"]=>
array(0) {
}
["pager"]=>
array(5) {
["use_pager"]=>
bool(false)
["items_per_page"]=>
int(10)
["element"]=>
int(0)
["offset"]=>
int(0)
["current_page"]=>
int(0)
}
["old_view"]=>
array(0) {
}
["vid"]=>
string(2) "48"
["name"]=>
string(7) "student"
["description"]=>
string(7) "Student"
["tag"]=>
string(0) ""
["view_php"]=>
string(0) ""
["is_cacheable"]=>
string(1) "0"
["display"]=>
array(2) {
["default"]=>
object(views_display)#11 (7) {
["db_table"]=>
string(13) "views_display"
["vid"]=>
string(2) "48"
["id"]=>
string(7) "default"
["display_title"]=>
string(8) "Defaults"
["display_plugin"]=>
string(7) "default"
["position"]=>
string(1) "1"
["display_options"]=>
array(2) {
["fields"]=>
array(5) {
["field_locatie_student_lid"]=>
array(14) {
["label"]=>
string(7) "Locatie"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(25) "field_locatie_student_lid"
["table"]=>
string(31) "node_data_field_locatie_student"
["field"]=>
string(25) "field_locatie_student_lid"
["relationship"]=>
string(4) "none"
}
["field_naam_student_value"]=>
array(14) {
["label"]=>
string(4) "Naam"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(24) "field_naam_student_value"
["table"]=>
string(28) "node_data_field_naam_student"
["field"]=>
string(24) "field_naam_student_value"
["relationship"]=>
string(4) "none"
}
["field_ugentid_student_value"]=>
array(14) {
["label"]=>
string(7) "UGentID"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(27) "field_ugentid_student_value"
["table"]=>
string(31) "node_data_field_ugentid_student"
["field"]=>
string(27) "field_ugentid_student_value"
["relationship"]=>
string(4) "none"
}
["field_voornaam_student_value"]=>
array(14) {
["label"]=>
string(8) "Voornaam"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(28) "field_voornaam_student_value"
["table"]=>
string(32) "node_data_field_voornaam_student"
["field"]=>
string(28) "field_voornaam_student_value"
["relationship"]=>
string(4) "none"
}
["field_voorkeur_student_value"]=>
array(14) {
["label"]=>
string(19) "Voorkeurstageplaats"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(28) "field_voorkeur_student_value"
["table"]=>
string(32) "node_data_field_voorkeur_student"
["field"]=>
string(28) "field_voorkeur_student_value"
["relationship"]=>
string(4) "none"
}
}
["filters"]=>
array(2) {
["type"]=>
array(9) {
["operator"]=>
string(2) "in"
["value"]=>
array(1) {
["student"]=>
string(7) "student"
}
["group"]=>
string(1) "0"
["exposed"]=>
bool(false)
["expose"]=>
array(2) {
["operator"]=>
bool(false)
["label"]=>
string(0) ""
}
["id"]=>
string(4) "type"
["table"]=>
string(4) "node"
["field"]=>
string(4) "type"
["relationship"]=>
string(4) "none"
}
["field_ugentid_student_value"]=>
array(9) {
["operator"]=>
string(9) "not empty"
["value"]=>
array(3) {
["value"]=>
string(0) ""
["min"]=>
string(0) ""
["max"]=>
string(0) ""
}
["group"]=>
string(1) "0"
["exposed"]=>
bool(false)
["expose"]=>
array(2) {
["operator"]=>
bool(false)
["label"]=>
string(0) ""
}
["id"]=>
string(27) "field_ugentid_student_value"
["table"]=>
string(31) "node_data_field_ugentid_student"
["field"]=>
string(27) "field_ugentid_student_value"
["relationship"]=>
string(4) "none"
}
}
}
}
["page_1"]=>
object(views_display)#43 (7) {
["db_table"]=>
string(13) "views_display"
["vid"]=>
string(2) "48"
["id"]=>
string(6) "page_1"
["display_title"]=>
string(6) "Pagina"
["display_plugin"]=>
string(4) "page"
["position"]=>
string(1) "2"
["display_options"]=>
array(1) {
["path"]=>
string(17) "studentenLijstCSV"
}
}
}
["type"]=>
string(6) "Normal"
["loaded"]=>
bool(true)
["executed"]=>
bool(false)
["built"]=>
bool(false)
["build_info"]=>
array(0) {
}
["attachment_before"]=>
string(0) ""
["attachment_after"]=>
string(0) ""
["get_total_rows"]=>
bool(true)
}
<div style="display: none" id="drupalforfirebug_general"><fieldset><legend>Drupal for Firebug General Messages</legend>There were no messages sent to the general log. Please use "firep($item, $optional_title)" to output messages to this console.</div><div style="display: none" id="drupalforfirebug_sql"><fieldset><legend>Devel Module is Not Installed</legend>Please install and enable the Devel Module to display the SQL queries.</fieldset></div><div style="display: none" id="drupalforfirebug_hook_form_alter">There was no form altering.</div><div style="display: none" id="drupalforfirebug_hook_user">There was no user processing.</div><div style="display: none" id="drupalforfirebug_hook_nodeapi">There was no node processing.</div><div style="display: none" id="drupalforfirebug_hook_views">There was no views processing.</div><div style="display: none" id="drupalforfirebug_php"><object style="width:100%;frameborder=0;height=100%;margin-bottom:-3px;" type="text/html" data="http://localhost/testplanning/?q=admin/firebug/exec"></object></div><div style="display: none" id="drupalforfirebug_hook_page_alter">This feature is only available in Drupal 7.</div>
why you not using just views?
$view = view_get_view('MY_VIEW_NAME');
$view->set_display('MY_DISPLAY'); // page_1 or block_1 ... block_n, ...page_n
$view->set_items_per_page(0);
$view->execute();
$result = $view->result;
$result will contains array of values of each row
I haven't actually tried this myself. First thing to do would be to execute the views query. This can be done with the execute function.
So doing something like this:
$view->execute('display_id');
Should populate the $view object with at least some data. The data available differs through the different layers of theme functions, so you might not get what you want. But this is the best method I can think of.