Block View for Recent Sales

Posts: 21
Joined: 01/13/2008

Hi,

I am trying to create a block view for recent sales, however I can't get it working properly. I want to add custom CCK fields such as field_date and field_venue. However I can't get them to display. The only items I can get to show up are $product->title and $product->price.

Here is my code:

<?php
$result
= db_query("SELECT * FROM {uc_orders} ORDER BY created DESC LIMIT 5");
while (
$order = db_fetch_object($result)) {

 
$product_result = db_query("SELECT * FROM {uc_order_products} WHERE order_id = %d", $order->order_id);
  while (
$product = db_fetch_object($product_result)) {
   
$product_node = node_load(array('nid' => $product->order_product_id));

   
$rows[] = array($product->title, $node->$field_date, $node->field_venue, $product->price);
  }
}
print
theme('table', array('ID #', 'Date', 'Venue', 'Sold Price'), $rows);


?>

Posts: 888
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

Shouldn't it be something like $node->field_date[0]['view'] ? Do a print_r() on the node object to see exactly where the information is stored.

--

<tr>.

Posts: 1228
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Yeah I think it would be '#value' instead of 'view' or if you want to render the content itself it might be a little different. View perhaps would work in that case depending on the field type? One way I have found helpful is to use the Views theme wizard to get a list of all the vars I can use. Contemplate also is helpful in that way..

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 21
Joined: 01/13/2008

The only challenge with views and products is that you can't set the filter to show by the order status. Do you have any quick suggestions for including some code that will allow me filter by orders completed in the block? So that it only displays "The Latest Products Sold".

Thanks.

~ Kristy