Zen Cart Logo
Forums / Managing Customers and Orders / Add "Product_Name" to each line in Orders.php

Add "Product_Name" to each line in Orders.php

Views: 1,928

Results 1 to 7 of 7
14 Feb 2011, 8:30 PM
#1
zapme1 avatar

zapme1

Zen Follower

Join Date:
Jan 2011
Location:
Ohio
Posts:
114
Plugin Contributions:
0

Add "Product_Name" to each line in Orders.php

Hi All,

One of my stores sells "Classes", and each class date is a product. In the admin, while viewing orders.php, I see the Customers Name, and Company Name on the next line.

**I would like to add a 3rd line under Company Name that displays the "product_name" (aka: class date) that the customer has ordered!
**
It looks like this code needs to be added in orders.php around line 820, but have had no luck with the proper code to add!

Tried adding $order->products[$i]['name'], which is the code that displays in the right sidebox, and displays the product (class) ordered, but this is visible ONLY when that individual customer is highlighted!

I would like to display the product_name for EACH customer order listing!

Can someone please help me with the code that I need to use?

Thanks in advance....

16 Feb 2011, 2:24 AM
#2
zapme1 avatar

zapme1

Zen Follower

Join Date:
Jan 2011
Location:
Ohio
Posts:
114
Plugin Contributions:
0

Re: Add "Product_Name" to each line in Orders.php

Does no one have any ideas about this?:(

16 Feb 2011, 2:41 AM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Add "Product_Name" to each line in Orders.php

So if there is 1 to 100 Products, you want them listed on the main listing and not just the right panel? :unsure:

16 Feb 2011, 2:54 AM
#4
zapme1 avatar

zapme1

Zen Follower

Join Date:
Jan 2011
Location:
Ohio
Posts:
114
Plugin Contributions:
0

Re: Add "Product_Name" to each line in Orders.php

Ajeh:

So if there is 1 to 100 Products, you want them listed on the main listing and not just the right panel? :unsure:

Well, yes, but in my case I give classes, and each customer will have only 1 per year (for yearly continuing education). In very few instances, there will be no more then 3, but only for a small hand-full!

I know that I can filter the list to just show me the customers for a certain product (class), but just wanted to have the purchased class visible with a quick glance.

I could even remove the "company name", as I don't really need this displayed, and it would give me the extra line for the urchased class!

Thanks for your reply....

16 Feb 2011, 3:08 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Add "Product_Name" to each line in Orders.php

See if adding this below the row works for you:

<tr>
  <td class="dataTableContent" colspan="2"> </td>
  <td class="dataTableContent" colspan="6">
<?php
      $order = new order($orders->fields['orders_id']);
      for ($i=0; $i<sizeof($order->products); $i++) {
        echo $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'];
        if (sizeof($order->products[$i]['attributes']) > 0) {
          for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) {
            echo ' <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])) . '</i></nobr>';
          }
        }
        if ($i > MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING and MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING != 0) {
          echo TEXT_MORE;
          break;
        }
        echo '<br/>';
      }
?>
</td>
</tr>
16 Feb 2011, 3:51 AM
#6
zapme1 avatar

zapme1

Zen Follower

Join Date:
Jan 2011
Location:
Ohio
Posts:
114
Plugin Contributions:
0

Re: Add "Product_Name" to each line in Orders.php

Ajeh:

See if adding this below the row works for you:

<tr> <td class="dataTableContent" colspan="2"> </td> <td class="dataTableContent" colspan="6"> <?php $order = new order($orders->fields['orders_id']); for ($i=0; $i<sizeof($order->products); $i++) { echo $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name']; if (sizeof($order->products[$i]['attributes']) > 0) { for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) { echo ' <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value'])) . '</i></nobr>'; } } if ($i > MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING and MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING != 0) { echo TEXT_MORE; break; } echo '<br/>'; } ?> </td> </tr> ```

Outstanding! Thank you so much, Linda! :clap:

Just needed a little formatting for your code, and it worked like a charm. I removed the attribute code, as I have 3-4 attributes defined, but just needed the "qty & name".

I just enclosed within the existing <td> to keep the formatting straight!

<td class="dataTableContent"><?php echo '<a href="' . zen_href_link(FILENAME_CUSTOMERS, 'cID=' . $orders->fields['customers_id'], 'NONSSL') . '">' . zen_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW . ' ' . TABLE_HEADING_CUSTOMERS) . '</a> ' . $orders->fields['customers_name'] . ($orders->fields['customers_company'] != '' ? '<br />' . $orders->fields['customers_company'] : ''); ?>
<br />

<?php
      $order = new order($orders->fields['orders_id'])
      for ($i=0; $i<sizeof($order->products); $i++) {
         echo $order->products[$i]['qty'] . ' x ' .   $order->products[$i]['name'];

         if ($i > MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING and MAX_DISPLAY_RESULTS_ORDERS_DETAILS_LISTING != 0) {
             echo TEXT_MORE;
	     break;
	 }
	 echo '<br/>';
     }
?>
</td>

The code in Blue above is all I needed to add!

Once again, thank you very much for your quick help! :thumbsup:

16 Feb 2011, 5:12 AM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Add "Product_Name" to each line in Orders.php

You are most welcome ... glad this worked for you ... :smile: