Would it make sense to use the admin Packing Slip feature instead? This could be less intrusive to code because it deals with data already saved in the database rather than merely an array of data that hasn't been stored yet.
To do it in the storefront, you need to edit the create_add_products() element of the order class, and before looping through $this->products, you need to sort that array based on model number. A challenging task depending on your definition of challenging.
To do it for the admin packing-slip, edit the Admin order.php class and change the order-by clause on the query to the orders_products table, using something like this two-step approach:
/admin/packingslip.php
at the top of the code section, ie: line 22 or so, you'll see:
Code:
require('includes/application_top.php');
add these two new lines above it:
Code:
// added for sort-by-model-number:
define('PACKSLIPSORTBYMODEL', 'true');
and
/admin/includes/classes/order.php
around line 115:
Code:
$orders_products = $db->Execute("select orders_products_id, products_id, products_name, products_model,
products_price, products_tax, products_quantity,
final_price, onetime_charges,
product_is_free
from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = '" . (int)$order_id . "'
order by orders_products_id");
becomes:
Code:
$orders_products = $db->Execute("select orders_products_id, products_id, products_name, products_model,
products_price, products_tax, products_quantity,
final_price, onetime_charges,
product_is_free
from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = '" . (int)$order_id . "'
order by " . (defined('PACKSLIPSORTBYMODEL') && PACKSLIPSORTBYMODEL=='true' ? "products_model" : "orders_products_id");
Bookmarks