mat123slade Posted January 18, 2005 Posted January 18, 2005 Hi, I'm trying to add a field in the Order Page in the admin, I would like a column to show the name of the user group (Retailer, Shop, wholesaler etc) that I have set up with Seperate Price Per Customer. I have so far come up with this : I'm adding the column name here (for people interested admin/orders.php) : <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" width='30'><?php echo 'ID #'; ?></td> <td class="dataTableHeadingContent">Group</td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMERS; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td> <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DATE_PURCHASED; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> </tr> I haven't bothered with language, Group will do fine (ID # is so I can show the ID number of the order, that might help somebody out). And for the content : <td class="<?php echo $current_row; ?>"><?php echo '<font face=verdana size=1>' . $orders['orders_id']; ?></font></td> <td class="<?php echo $current_row; ?>"><?php echo '' . $customers['customers_group_id']; ?></font></td> <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $orders['customers_name']; ?></td> <td class="dataTableContent" align="right"><?php echo strip_tags($orders['order_total']); ?></td> <td class="dataTableContent" align="center"><?php echo tep_datetime_short($orders['date_purchased']); ?></td> <td class="dataTableContent" align="right"><?php echo $orders['orders_status_name']; ?></td> <td class="dataTableContent" align="right"><?php if (isset($oInfo) && is_object($oInfo) && ($orders['orders_id'] == $oInfo->orders_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID')) . 'oID=' . $orders['orders_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> So the bit of code that I have got wrong is <?php echo '' . $customers['customers_group_id']; ?> Anyone know what I should put here ? Actualy I think it might be correct, but I have been told I am calling the group_id from the TABLE_ORDERS, which does not contain a group_id. I must call it from the TABLE_CUSTOMERS. The problem is, I'm not sure how to go about that. Anyone have an idea? I'm sure there isn't much more to do so that it works, it must be simple... Thanx a lot.
boxtel Posted January 18, 2005 Posted January 18, 2005 Hi, I am ready to pay a small fee to get this working. Please contact me by pm for your proposals. I'm trying to add a field in the Order Page in the admin, I would like a column to show the name of the user group (Retailer, Shop, wholesaler etc) that I have set up with Seperate Price Per Customer. I have so far come up with this : I'm adding the column name here (for people interested admin/orders.php) : <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" width='30'><?php echo 'ID #'; ?></td> <td class="dataTableHeadingContent">Group</td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMERS; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td> <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DATE_PURCHASED; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> </tr> I haven't bothered with language, Group will do fine (ID # is so I can show the ID number of the order, that might help somebody out). And for the content : <td class="<?php echo $current_row; ?>"><?php echo '<font face=verdana size=1>' . $orders['orders_id']; ?></font></td> <td class="<?php echo $current_row; ?>"><?php echo '' . $customers['customers_group_id']; ?></font></td> <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $orders['customers_name']; ?></td> <td class="dataTableContent" align="right"><?php echo strip_tags($orders['order_total']); ?></td> <td class="dataTableContent" align="center"><?php echo tep_datetime_short($orders['date_purchased']); ?></td> <td class="dataTableContent" align="right"><?php echo $orders['orders_status_name']; ?></td> <td class="dataTableContent" align="right"><?php if (isset($oInfo) && is_object($oInfo) && ($orders['orders_id'] == $oInfo->orders_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID')) . 'oID=' . $orders['orders_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> So the bit of code that I have got wrong is <?php echo '' . $customers['customers_group_id']; ?> Anyone know what I should put here ? Actualy I think it might be correct, but I have been told I am calling the group_id from the TABLE_ORDERS, which does not contain a group_id. I must call it from the TABLE_CUSTOMERS. The problem is, I'm not sure how to go about that. Anyone have an idea? I'm sure there isn't much more to do so that it works, it must be simple... Thanx a lot. <{POST_SNAPBACK}> sure you are actually selecting the group_id in the customers query that is probably up there somewhere ? Treasurer MFC
mat123slade Posted January 18, 2005 Author Posted January 18, 2005 That is what I am unsure of... I don't know what to put or how to put it. I have tried different combinations, but my knowledge in Php is not good enough to find out where the error is coming from, and I'm not even sure if I'm trying to get the info from the correct table...
boxtel Posted January 18, 2005 Posted January 18, 2005 That is what I am unsure of... I don't know what to put or how to put it. I have tried different combinations, but my knowledge in Php is not good enough to find out where the error is coming from, and I'm not even sure if I'm trying to get the info from the correct table... <{POST_SNAPBACK}> in orders.php find this : $orders_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $orders_query_raw, $orders_query_numrows); $orders_query = tep_db_query($orders_query_raw); while ($orders = tep_db_fetch_array($orders_query)) { right after that add this : $customer_group_query_raw = "select customers_group_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $orders['customers_id'] . "'"; $customer_group_query = tep_db_query($customer_group_query_raw); $customer_group_array = tep_db_fetch_array($customer_group_query); $customer_group = $customer_group_array['customers_group_id']; then use $customer_group in the list Treasurer MFC
mat123slade Posted January 18, 2005 Author Posted January 18, 2005 Hi, thanx for your help, I'm sorry I'm going to ask questions... I wish I could get this right by myself ! When you say list do you mean in this part of the code : <?php echo '' . $customers['customers_group']; ?> As I have tried many different combinations after adding the code you have given me without any success. could you possibly be a little more precise? Thanx again.
boxtel Posted January 18, 2005 Posted January 18, 2005 Hi, thanx for your help, I'm sorry I'm going to ask questions... I wish I could get this right by myself ! When you say list do you mean in this part of the code : <?php echo '' . $customers['customers_group']; ?> As I have tried many different combinations after adding the code you have given me without any success. could you possibly be a little more precise? Thanx again. <{POST_SNAPBACK}> <?php echo $customer_group; ?> Treasurer MFC
boxtel Posted January 18, 2005 Posted January 18, 2005 <?php echo $customer_group; ?> <{POST_SNAPBACK}> in the 2 queries above there you see this : o.customers_name, o.payment_method change those to this : o.customers_name, o.customers_id, o.payment_method and in the query it should be customers_groups_id so it should be like this : $customer_group_query_raw = "select customers_groups_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $orders['customers_id'] . "'"; echo $orders['customers_id']; echo $customer_group_query_raw; $customer_group_query = tep_db_query($customer_group_query_raw); $customer_group_array = tep_db_fetch_array($customer_group_query); $customer_group = $customer_group_array['customers_groups_id']; echo $customer_group; Treasurer MFC
mat123slade Posted January 18, 2005 Author Posted January 18, 2005 This is the error message I get : select customers_groups_id from customers where customers_id = ''1054 - Unknown column 'customers_groups_id' in 'field list' select customers_groups_id from customers where customers_id = '' Let me show the code : ------------------- $orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id DESC"; ------------------- $orders_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $orders_query_raw, $orders_query_numrows); $orders_query = tep_db_query($orders_query_raw); while ($orders = tep_db_fetch_array($orders_query)) { $customer_group_query_raw = "select customers_groups_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $orders['customers_id'] . "'"; echo $orders['customers_id']; echo $customer_group_query_raw; $customer_group_query = tep_db_query($customer_group_query_raw); $customer_group_array = tep_db_fetch_array($customer_group_query); $customer_group = $customer_group_array['customers_groups_id']; ------------------- <?php echo $customer_group; ?> Is there something wrong there ?
boxtel Posted January 18, 2005 Posted January 18, 2005 This is the error message I get :Let me show the code : ------------------- $orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id DESC"; ------------------- $orders_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $orders_query_raw, $orders_query_numrows); $orders_query = tep_db_query($orders_query_raw); while ($orders = tep_db_fetch_array($orders_query)) { $customer_group_query_raw = "select customers_groups_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $orders['customers_id'] . "'"; echo $orders['customers_id']; echo $customer_group_query_raw; $customer_group_query = tep_db_query($customer_group_query_raw); $customer_group_array = tep_db_fetch_array($customer_group_query); $customer_group = $customer_group_array['customers_groups_id']; ------------------- <?php echo $customer_group; ?> Is there something wrong there ? <{POST_SNAPBACK}> ok, then your field is called customers_group_id, mine is customers_groups_id. then use the query I gave you before. Treasurer MFC
mat123slade Posted January 18, 2005 Author Posted January 18, 2005 I now have : $customer_group_query_raw = "select customers_group_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $orders['customers_id'] . "'"; $customer_group_query = tep_db_query($customer_group_query_raw); $customer_group_array = tep_db_fetch_array($customer_group_query); $customer_group = $customer_group_array['customers_group_id']; <?php echo $customer_group; ?> And still no success. I don't get the error message, but nothing is showing up there. I have the impression I understand everything you have explained to me now... And it all seams to be correct and corresponds with the database, there don't seam to be any "s" problems on the end of customer. Do you have another idea? I have changed things around but have had no luck.
boxtel Posted January 19, 2005 Posted January 19, 2005 I now have : $customer_group_query_raw = "select customers_group_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $orders['customers_id'] . "'"; $customer_group_query = tep_db_query($customer_group_query_raw); $customer_group_array = tep_db_fetch_array($customer_group_query); $customer_group = $customer_group_array['customers_group_id']; <?php echo $customer_group; ?> And still no success. I don't get the error message, but nothing is showing up there. I have the impression I understand everything you have explained to me now... And it all seams to be correct and corresponds with the database, there don't seam to be any "s" problems on the end of customer. Do you have another idea? I have changed things around but have had no luck. <{POST_SNAPBACK}> verify that you have a field in customers called customers_group_id and that it contains data, not null. and verify that you did this : in the 2 queries above there you see this : o.customers_name, o.payment_method change those to this : o.customers_name, o.customers_id, o.payment_method there are 3 queries up there that do a select on the orders table. the first also selects the customers_id, the last 2 do not. So we need them to do it as well. Treasurer MFC
boxtel Posted January 19, 2005 Posted January 19, 2005 Hi,I'm trying to add a field in the Order Page in the admin, I would like a column to show the name of the user group (Retailer, Shop, wholesaler etc) that I have set up with Seperate Price Per Customer. I have so far come up with this : I'm adding the column name here (for people interested admin/orders.php) : <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" width='30'><?php echo 'ID #'; ?></td> <td class="dataTableHeadingContent">Group</td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMERS; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td> <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DATE_PURCHASED; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> </tr> I haven't bothered with language, Group will do fine (ID # is so I can show the ID number of the order, that might help somebody out). And for the content : <td class="<?php echo $current_row; ?>"><?php echo '<font face=verdana size=1>' . $orders['orders_id']; ?></font></td> <td class="<?php echo $current_row; ?>"><?php echo '' . $customers['customers_group_id']; ?></font></td> <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $orders['customers_name']; ?></td> <td class="dataTableContent" align="right"><?php echo strip_tags($orders['order_total']); ?></td> <td class="dataTableContent" align="center"><?php echo tep_datetime_short($orders['date_purchased']); ?></td> <td class="dataTableContent" align="right"><?php echo $orders['orders_status_name']; ?></td> <td class="dataTableContent" align="right"><?php if (isset($oInfo) && is_object($oInfo) && ($orders['orders_id'] == $oInfo->orders_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID')) . 'oID=' . $orders['orders_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> So the bit of code that I have got wrong is <?php echo '' . $customers['customers_group_id']; ?> Anyone know what I should put here ? Actualy I think it might be correct, but I have been told I am calling the group_id from the TABLE_ORDERS, which does not contain a group_id. I must call it from the TABLE_CUSTOMERS. The problem is, I'm not sure how to go about that. Anyone have an idea? I'm sure there isn't much more to do so that it works, it must be simple... Thanx a lot. <{POST_SNAPBACK}> just looked at that contribution and what I find strange is that both the customers_group_id and the customers_group_name are in the customers table. Not so good data modelling. But still, that means that you can extend the query to also select and display the group name. like so: $customer_group_query_raw = "select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS . " where customers_id = '" . $orders['customers_id'] . "'"; $customer_group_query = tep_db_query($customer_group_query_raw); $customer_group_array = tep_db_fetch_array($customer_group_query); echo $customer_group_array['customers_group_id']; echo $customer_group_array['customers_group_name']; Treasurer MFC
mat123slade Posted January 25, 2005 Author Posted January 25, 2005 I finaly have it working really well. Thank you ever so much for your help. I realise now that it was not complexe, I just wish after the amount of time I've been using OsCommerce that I could just see solutions to problems like this and do them myself... All the Best
Recommended Posts
Archived
This topic is now archived and is closed to further replies.