i am having trouble figuring out how to render my array fields values for specific fields. So far i've managed to query my db and collect the node values and save it to my cart of items. However, i am unsure how to echo these into a table for users to view in the most efficient way for fields related only to itemname, quantity and field_id.
- The following is my code to load entities into an array:
if (isset($result['node'])) { $scart_items_nids = array_keys($result['node']); $scart_items = entity_load('node', $scart_items_nids); }
- I run the following output to view the array:
echo "<pre>"; print_r($scart_items); echo "</pre>";
This is the output i get:
Array ( [145] => stdClass Object ( [vid] => 264 [uid] => 1 [title] => Rxk [log] => [status] => 1 [comment] => 0 [promote] => 0 [sticky] => 0 [nid] => 145 [type] => shopping_cart [language] => und [created] => 1544177045 [changed] => 1544177045 [tnid] => 0 [translate] => 0 [revision_timestamp] => 1544177045 [revision_uid] => 1 [field_id] => Array ( [und] => Array ( [0] => Array ( [value] => 21 [format] => [safe_value] => 21 ) ) ) [field_itemid] => Array ( [und] => Array ( [0] => Array ( [value] => 11 [format] => [safe_value] => 11 ) ) ) [field_itemname] => Array ( [und] => Array ( [0] => Array ( [value] => Example Tour [format] => [safe_value] => Example Tour ) ) ) [field_quantity] => Array ( [und] => Array ( [0] => Array ( [value] => 1 [format] => [safe_value] => 1 ) ) ) [cid] => 0 [last_comment_timestamp] => 1544177045 [last_comment_name] => [last_comment_uid] => 1 [comment_count] => 0 [name] => administrator [picture] => 8 [data] => a:6:{s:16:"ckeditor_default";s:1:"t";s:20:"ckeditor_show_toggle";s:1:"t";s:14:"ckeditor_width";s:4:"100%";s:13:"ckeditor_lang";s:2:"en";s:18:"ckeditor_auto_lang";s:1:"t";s:7:"contact";i:0;} ) [146] => stdClass Object ( [vid] => 265 [uid] => 1 [title] => Test [log] => [status] => 1 [comment] => 0 [promote] => 0 [sticky] => 0 [nid] => 146 [type] => shopping_cart [language] => und [created] => 1544177049 [changed] => 1544177049 [tnid] => 0 [translate] => 0 [revision_timestamp] => 1544177049 [revision_uid] => 1 [field_id] => Array ( [und] => Array ( [0] => Array ( [value] => 12 [format] => [safe_value] => 12 ) ) ) [field_itemid] => Array ( [und] => Array ( [0] => Array ( [value] => 11 [format] => [safe_value] => 11 ) ) ) [field_itemname] => Array ( [und] => Array ( [0] => Array ( [value] => Sample Tour [format] => [safe_value] => Sample Tour ) ) ) [field_quantity] => Array ( [und] => Array ( [0] => Array ( [value] => 1 [format] => [safe_value] => 1 ) ) ) [cid] => 0 [last_comment_timestamp] => 1544177049 [last_comment_name] => [last_comment_uid] => 1 [comment_count] => 0 [name] => administrator [picture] => 8 [data] => a:6:{s:16:"ckeditor_default";s:1:"t";s:20:"ckeditor_show_toggle";s:1:"t";s:14:"ckeditor_width";s:4:"100%";s:13:"ckeditor_lang";s:2:"en";s:18:"ckeditor_auto_lang";s:1:"t";s:7:"contact";i:0;} )