Forums / General Questions / Flagging orders containing certain products - please advise

Flagging orders containing certain products - please advise

Views: 741

Results 1 to 6 of 6
19 Aug 2014, 6:58 PM
#1
chris_stackhouse avatar

chris_stackhouse

New Zenner

Join Date:
Aug 2014
Location:
Washington Township, Gloucester County, New Jersey, United States
Posts:
11
Plugin Contributions:
0

Flagging orders containing certain products - please advise

I would like to be able to flag orders that contain certain products. Most of our products are custom made to specification, however, we are starting to keep an inventory of our most popular selections on hand and available in a "Quick-Ship" category. Zen Cart already flags products in the order list where the customer's billing and shipping address don't align. What I need is some help with code (or at least a push in the right direction) that will compare the contents of a customer's order and flag it in the order list with indicators if it contains items from certain categories (or certain item id numbers) .

Here's the original code form admin/orders.php that is comparing billing and shipping

   $show_difference = '';
    if (($orders->fields['delivery_name'] != $orders->fields['billing_name'] and $orders->fields['delivery_name'] != '')) {
        $show_difference = zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', TEXT_BILLING_SHIPPING_MISMATCH, 10, 10) . ' ';
      }
      if (($orders->fields['delivery_street_address'] != $orders->fields['billing_street_address'] and $orders->fields['delivery_street_address'] != '')) {
        $show_difference = zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', TEXT_BILLING_SHIPPING_MISMATCH, 10, 10) . ' ';
    }

Attachment 14419

19 Aug 2014, 8:37 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Flagging orders containing certain products - please advise

You can probably try to adapt this code ...

This is checking for products_id 12 in the Order and if found it will show the yellow icon next to the orders_id, the code for around line 883 is marked in RED:
/your_secret_admin/orders.php

      $show_payment_type = $orders->fields['payment_module_code'] . '<br />' . $orders->fields['shipping_module_code'];
[B]// bof: check order contents
      $show_special_products = '';
      $order = new order($orders->fields['orders_id']);
      for ($i=0; $i<sizeof($order->products); $i++) {
        if ((int)$order->products[$i]['id'] == 12) {
          $show_special_products = $oInfo->orders_id . zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif', 'Special Products', 10, 10);
          break;
        }
      }
// eof: check order contents
[/B]?>
                <td class="dataTableContent" align="right"><?php echo [B]$show_special_products . [/B]$show_difference . $orders->fields['orders_id']; ?></td>

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Aug 2014, 5:01 PM
#3
chris_stackhouse avatar

chris_stackhouse

New Zenner

Join Date:
Aug 2014
Location:
Washington Township, Gloucester County, New Jersey, United States
Posts:
11
Plugin Contributions:
0

Re: Flagging orders containing certain products - please advise

Thank you so much Linda! I decided to take it a step further and add it as two configurable fields into my super orders config screen. Flags yellow for Quick-Ship items and green for Wholesale items. Hard to believe this hasn't been done yet. We already caught 3 orders from the last couple days that should have been moved to our Quick-Ship status. It's extremely useful for us. I will post the code in its entirety.
Here's the end result:

Attachment 14427

Here's the config screen:

Attachment 14428

20 Aug 2014, 5:19 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Flagging orders containing certain products - please advise

Thanks for the update that this was able to work for you ... :smile:

To help others, you might post the code that you used to adapt that code ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

20 Aug 2014, 7:31 PM
#5
chris_stackhouse avatar

chris_stackhouse

New Zenner

Join Date:
Aug 2014
Location:
Washington Township, Gloucester County, New Jersey, United States
Posts:
11
Plugin Contributions:
0

Re: Flagging orders containing certain products - please advise

Flag Orders in Super Orders - 1.0 by Chris Stackhouse

Licensing

License is GNU GPL. Freedom baby, yeah.

Requires

-Requires Zen Cart v1.5.1 (may work with previous or future versions, not tested).
-Requires Super Orders 4.0.9 (may work with previous or future versions, not tested).

Files Involved

-Modifies Core Files:
admin/includes/languages/english/orders.php
admin/includes/orders.php
-Modifies Super Orders file:
admin/includes/init-includes/init_so_config.php
-Requires re-uploading Super Orders file (file deletes itself after first admin load)
admin/includes/auto_loaders/config.so

What is Flag Orders in Super Orders (FOISO)?

FOISO is a modification to super orders that flags orders in the order listing if the order contains certain items (product ids) defined by the admin in much the same way the order listing already flags orders with a red dot when the billing and shipping info mismatch. A yellow dot wll appear next to the order ID if an order contains items from Category 1 (defined by default as Quick-Ship) and a green dot if it contains items from Category 2 (defined by default as Wholesale). You can re-define the language files to reflect in the legend any reason you want for flagging these specific categories of items. Easily define the product IDs you wish to flag for each category by entering a string of product ids separated by commas in the two new fields at the bottom of the Admin-->Config-->Super Orders.

Installation Instructions

  1. Merge the following changes into admin/includes/init-includes/init_so_config.php
    around line 244:

//-- SUPER ORDERS VERSION
$sql = "INSERT IGNORE INTO ".DB_PREFIX."configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES (NULL, 'Super Orders Version', 'SO_VERSION', '4.0.5', 'Super Orders version', '".$so_configuration_id."', 100, NULL, now(), NULL, NULL)";
$db->Execute($sql);
////////////// START FOISO EDIT ////////////////////////
//-- Flag Products for FOISO Category 1
$sql = "INSERT IGNORE INTO ".DB_PREFIX."configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES (NULL, 'Product IDs to Flag for FOISO Category 1', 'FOISO_CAT_ONE_PRODUCT_ID_LIST', '', 'Enter the product id numbers separated by a comma that you wish to flag for FOISO Category 1 in the Order Listing', '".$so_configuration_id."', 105, now(), now(), NULL , NULL)";
$db->Execute($sql);
//-- Flag Products for FOISO Category 2
$sql = "INSERT IGNORE INTO ".DB_PREFIX."configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES (NULL, 'Product IDs to Flag for FOISO Category 2', 'FOISO_CAT_TWO_PRODUCT_ID_LIST', '', 'Enter the product id numbers separated by a comma that you wish to flag for FOISO Category 2 in the Order Listing', '".$so_configuration_id."', 110, now(), now(), NULL , NULL)";
$db->Execute($sql);
////////////// END FOISO EDIT ////////////////////////////
if(file_exists(DIR_FS_ADMIN . DIR_WS_INCLUDES . 'auto_loaders/config.so.php'))


  1. Re-upload admin/includes/auto_loaders/config.so from Super Orders. No changes necessary.

  2. Make desired changes to and merge the following into admin/includes/languages/english/orders.php:
    around line 168


define('TEXT_ICON_LEGEND', 'Action Icon Legend:');
define('TEXT_BILLING_SHIPPING_MISMATCH', 'Billing and Shipping do not match');
///////// Begin FOISO edit
// FOISO - Define CAT1/CAT2 Legend
define ('SO_FLAG_ORDERS_CAT1_LEGEND', 'This Order Contains a Quick-Ship Product');
define ('SO_FLAG_ORDERS_CAT2_LEGEND', 'This Order Contains a Wholesale Product');
/////////// End FOISO - Define CAT1/CAT2 Legend
define('TEXT_INFO_EXPIRED_DATE', 'Expired Date:<br />');
define('TEXT_INFO_EXPIRED_COUNT', 'Expired Count:<br />');


  1. Merge the following code into admin/includes/orders.php

around 1519 ( in my heavily modified orders.php)


'text' => TEXT_ALL_ORDERS)), $orders_statuses), $_GET['status'], 'onChange="this.form.submit();"');
echo zen_hide_session_id();
?>
</td>
</form></tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
///////// BEGIN FOISO REPLACE LEGEND
<td class="smallText"><?php
$spacer = zen_image(DIR_WS_IMAGES . 'pixel_trans.gif', 7, 7);

		 echo TEXT_LEGEND . ' ' . zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', TEXT_BILLING_SHIPPING_MISMATCH, 10, 10) . ' ' . TEXT_BILLING_SHIPPING_MISMATCH . $spacer; ?>
        
                 <?php echo zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif', SO_FLAG_ORDERS_CAT1_LEGEND, 10, 10) . ' ' . SO_FLAG_ORDERS_CAT1_LEGEND . $spacer ?>
                 
                 <?php echo zen_image(DIR_WS_IMAGES . 'icon_status_green.gif', SO_FLAG_ORDERS_CAT2_LEGEND, 10, 10) . ' ' . SO_FLAG_ORDERS_CAT2_LEGEND . $spacer ?>
      </td>
      //////////////END FOISO REPLACE LEGEND
      <tr>
        <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr class="dataTableHeadingRow">
<?php // Sort Listing switch ($_GET['list_order']) { ***************************************************** 5. Again, Merge the following code into admin/includes/orders.php around 1692 (in my heavily modified orders.php) ***************************************************** $show_payment_type = $orders->fields['payment_module_code'] . '<br />' . $orders->fields['shipping_module_code']; $close_status = so_close_status($orders->fields['orders_id']); if ($close_status) $class = "status-" . $close_status['type']; else $class = "dataTableContent"; /////////////// BEGIN FOISO EDIT /////////////////////// //creates a spacer $spacer = zen_image(DIR_WS_IMAGES . 'pixel_trans.gif', 10, 10); //begin check order contents - FOISO Cat 1 $show_FOISO_cat1_products = ' '; $cat1_string_array = FOISO_CAT_ONE_PRODUCT_ID_LIST; $cat1_int_array = array_map('intval', explode(',', $cat1_string_array)); $order = new order($orders->fields['orders_id']); foreach ($cat1_int_array as $cat1_value) for ($i=0; $i<sizeof($order->products); $i++) { if ((int)$order->products[$i]['id'] == $cat1_value) { $show_FOISO_cat1_products = zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif', SO_FLAG_ORDERS_CAT1_LEGEND, 10, 10); break; } } // end check order contents - FOISO Cat 1 // begin check order contents - FOISO Cat 2 $show_FOISO_cat2_products = ' '; $cat2_string_array = FOISO_CAT_TWO_PRODUCT_ID_LIST; $cat2_int_array = array_map('intval', explode(',', $cat2_string_array)); $order = new order($orders->fields['orders_id']); foreach ($cat2_int_array as $cat2_value) for ($i=0; $i<sizeof($order->products); $i++) { if ((int)$order->products[$i]['id'] == $cat2_value) { $show_FOISO_cat2_products = zen_image(DIR_WS_IMAGES . 'icon_status_green.gif', SO_FLAG_ORDERS_CAT2_LEGEND, 10, 10); break; } } // end check order contents - FOISO Cat 2 ?>
           <td class="dataTableContent" align="left"><?php echo $orders->fields['orders_id'] . $spacer . $show_difference . $show_FOISO_cat1_products . $show_FOISO_cat2_products; ?> </td>
 <? php

///////////////// END FOISO EDIT /////////////////////////
?>
<td class="dataTableContent" align="left"><?php echo $show_payment_type; ?></td>

<!-- <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'] : ''); ?></td> //-->
  1. One more time, merge the following code into admin/includes/orders.php
    around 1908 (in my heavily modded orders.php)

             <tr>
                <td align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_status_red.gif', TEXT_BILLING_SHIPPING_MISMATCH, 10, 10); ?></td>
                <td class="smallText"><?php echo TEXT_BILLING_SHIPPING_MISMATCH; ?></td>
              </tr>
      <?  php  
//////////////// BEGIN FOISO LEGEND ///////////////

?>
<td align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif', SO_FLAG_ORDERS_CAT1_LEGEND, 10, 10); ?></td>
<td class="smallText"><?php echo SO_FLAG_ORDERS_CAT1_LEGEND; ?></td>
</tr>

                                  <td align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_status_green.gif', SO_FLAG_ORDERS_CAT2_LEGEND, 10, 10); ?></td>
                <td class="smallText"><?php echo SO_FLAG_ORDERS_CAT2_LEGEND; ?></td>
              </tr>
             <? php

////////////////////// END FOISO LEGEND //////////////////
?>

              <tr>
                <td align="center"><?php echo zen_image(DIR_WS_IMAGES . 'icon_cust_info.gif', MINI_ICON_INFO); ?></td>
                <td class="smallText"><?php echo MINI_ICON_INFO; ?></td>
              </tr>

Special Thanks to Linda McGrath for helping with order checking loop.
If you enjoy this mod and would like to make a donation, send it over to http://www.zen-cart.com/donate and support the Zen Cart open source community.

20 Aug 2014, 7:41 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Flagging orders containing certain products - please advise

Thanks for the update we really appreciate it and this can help others that might need it as well ... :cool:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!