jonesevan007 Posted February 1, 2009 Share Posted February 1, 2009 Hey guys, On the customer's account page (account.php) where it shows their order status (pending, processing, shipped etc.) how can I show an image for each different order status? I've created a new column in the orders_status database table entitled "order_status_image" and filled it out with an html <img> tag that points to a picture that I want shown on the customer's account dashboard. Below is the account.php query that calls all of the other goodies (order id, data ordered, name, order status) : <?php $orders_query = tep_db_query("select o.orders_id, o.date_purchased, o.delivery_name, o.delivery_country, o.billing_name, o.billing_country, ot.text as order_total, s.orders_status_name from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$customer_id . "' and o.orders_id = ot.orders_id and ot.class = 'ot_total' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' order by orders_id desc limit 3"); while ($orders = tep_db_fetch_array($orders_query)) { if (tep_not_null($orders['delivery_name'])) { $order_name = $orders['delivery_name']; $order_country = $orders['delivery_country']; } else { $order_name = $orders['billing_name']; $order_country = $orders['billing_country']; } ?> <tr class="moduleRow" onMouseOver="rowOverEffect(this)" onMouseOut="rowOutEffect(this)" onClick="document.location.href='<?php echo tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL'); ?>'"> <td class="main" width="80"><?php echo tep_date_short($orders['date_purchased']); ?></td> <td style="padding-left: 15px;" class="main"><?php echo ' Order#' . $orders['orders_id']; ?></td> <td style="padding-left: 15px;" class="main"><nobr><?php echo tep_output_string_protected($order_name) . ', ' . $order_country; ?></nobr></td> <td style="padding-left: 10px;" class="main"><nobr><?php echo $orders['orders_status_name']; ?></nobr></td> <td style="padding-left: 10px;" class="main" align="right"><?php echo $orders['order_total']; ?></td> <td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td> </tr> <?php } ?> What I'm trying to do is have that associated order_status_image field also display in another table row. I'm good enough with php to statically call a particular field from the database but I'm not yet good enough to have the images I've created actually be associated with a particular customer's order (like the oscommerce code does above for order_status_name). Any help getting this order_status_image query off the ground would be greatly appreciated. Link to comment Share on other sites More sharing options...
jonesevan007 Posted February 14, 2009 Author Share Posted February 14, 2009 Here's the solution I've built, feel free to use it. Note that this requires creating another column in the database in the order status table called order_status_image which houses the URLs of the order status images. (in account.php) <?php $orders_query = tep_db_query("select o.orders_id, o.date_purchased, o.delivery_name, o.delivery_country, o.billing_name, o.billing_country, ot.text as order_total, s.orders_status_name, s.order_status_image from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$customer_id . "' and o.orders_id = ot.orders_id and ot.class = 'ot_total' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' order by orders_id desc limit 10"); while ($orders = tep_db_fetch_array($orders_query)) { if (tep_not_null($orders['delivery_name'])) { $order_name = $orders['delivery_name']; $order_country = $orders['delivery_country']; } else { $order_name = $orders['billing_name']; $order_country = $orders['billing_country']; } ?> <tr class="moduleRow" onMouseOver="rowOverEffect(this)" onMouseOut="rowOutEffect(this)" onClick="document.location.href='<?php echo tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL'); ?>'"> <td class="main" width="80"><?php echo tep_date_short($orders['date_purchased']); ?></td> <td style="padding-left: 15px;" class="main"><?php echo ' Order#' . $orders['orders_id']; ?></td> <td style="padding-left: 15px;" class="main"><nobr><?php echo tep_output_string_protected($order_name) . ', ' . $order_country; ?></nobr></td> <td style="padding-left: 10px;" class="main" align="right"><?php echo $orders['order_total']; ?></td> <td class="main" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . '">' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . '</a>'; ?></td> </tr> <tr> <td colspan="5" style="padding-left: 10px;" class="main"><nobr><?php echo $orders['orders_status_name'] . tep_image($orders['order_status_image'], $orders['orders_status_name']); ?></nobr></td> </tr> <?php } ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.