New Zenner
- Join Date:
- Jul 2007
- Posts:
- 22
- Plugin Contributions:
- 0
Product sort order on invoice
Hi I need to figure out if there is any way to get the product list on the invoice to be sorted after module name or product number.
Views: 6,277
New Zenner
Hi I need to figure out if there is any way to get the product list on the invoice to be sorted after module name or product number.
Oba-san
The current method is to have all products added to the cart in the method the customer sees it ...
Then from the checkout to the email to the account history to the order all match in this same method ...
To change the display in the order for the Admin that would then not match the customer's order ... you would have to customize the order class and include an order by based on what you are wanting to see ...
New Zenner
So you are telling me that the products are listed by the order the costumer puts them into the cart?
Oba-san
Yes ... if you look at the shopping_cart, then the checkout_confirmation, then the account_history_info, then the emails, then the orders ... you will find them in the same order ... :smile:
New Zenner
Hi Ajeh
Just a follow on question. I would like to have the products on the invoice and/or packing slip sorted by the model number so I can use a prefix on the model number to determine packing order.
I gather from what you have said that I need to edit the file /includes/classes/order.php and add an order by to the query that gathers the product information
$orders_products_query = "select orders_products_id, products_id, products_name,
products_model, products_price, products_tax,
products_quantity, final_price,
onetime_charges,
products_priced_by_attribute, product_is_free, products_discount_type, products_discount_type_from
from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = '" . (int)$order_id . "' order by products_model";
Let me know if I'm on the right track
Cheers
New Zenner
New Zenner
how about this:
$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 products_model");
New Zenner
how about changing (not adding) it to:
$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 products_model");
New Zenner
Thanks for the reply. But Where is this code file at? Can you be a little more specific as to change this to this in this file.
Thank you Again.
New Zenner
\admin\includes\classes\order.php
this is the original 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");
change order by orders_products_id to ```
order by products_model
New Zenner
Thank you so much... That worked.
Just one last thing though what can I do to make the "Edit Orders" page to be alphabetical as well?
Here's the location: admin/edit_orders.php
Here's the code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | [URL]http://www.zen-cart.com/index.php[/URL] |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | [URL]http://www.zen-cart.com/license/2_0.txt[/URL]. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [EMAIL="[email protected]"][email protected][/EMAIL] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: order.php 4774 2006-10-17 06:47:16Z drbyte $
//
class order {
var $info, $totals, $products, $customer, $delivery;
function order($order_id) {
$this->info = array();
$this->totals = array();
$this->products = array();
$this->customer = array();
$this->delivery = array();
$this->query($order_id);
}
function query($order_id) {
global $db;
$order = $db->Execute("select cc_cvv, customers_name, customers_company, customers_street_address,
customers_suburb, customers_city, customers_postcode, customers_id,
customers_state, customers_country, customers_telephone,
customers_email_address, customers_address_format_id, delivery_name,
delivery_company, delivery_street_address, delivery_suburb,
delivery_city, delivery_postcode, delivery_state, delivery_country,
delivery_address_format_id, billing_name, billing_company,
billing_street_address, billing_suburb, billing_city, billing_postcode,
billing_state, billing_country, billing_address_format_id,
coupon_code, payment_method, payment_module_code, shipping_method, shipping_module_code,
cc_type, cc_owner, cc_number, cc_expires, currency,
currency_value, date_purchased, orders_status, last_modified,
order_total, order_tax, ip_address
from " . TABLE_ORDERS . "
where orders_id = '" . (int)$order_id . "'");
$totals = $db->Execute("select title, text, class
from " . TABLE_ORDERS_TOTAL . "
where orders_id = '" . (int)$order_id . "'
order by sort_order");
while (!$totals->EOF) {
$this->totals[] = array('title' => $totals->fields['title'],
'text' => $totals->fields['text'],
'class' => $totals->fields['class']);
$totals->MoveNext();
}
$this->info = array('currency' => $order->fields['currency'],
'currency_value' => $order->fields['currency_value'],
'payment_method' => $order->fields['payment_method'],
'payment_module_code' => $order->fields['payment_module_code'],
'shipping_method' => $order->fields['shipping_method'],
'shipping_module_code' => $order->fields['shipping_module_code'],
'coupon_code' => $order->fields['coupon_code'],
'cc_type' => $order->fields['cc_type'],
'cc_owner' => $order->fields['cc_owner'],
'cc_number' => $order->fields['cc_number'],
'cc_cvv' => $order->fields['cc_cvv'],
'cc_expires' => $order->fields['cc_expires'],
'date_purchased' => $order->fields['date_purchased'],
'orders_status' => $order->fields['orders_status'],
'total' => $order->fields['order_total'],
'tax' => $order->fields['order_tax'],
'last_modified' => $order->fields['last_modified'],
'ip_address' => $order->fields['ip_address']
);
$this->customer = array('name' => $order->fields['customers_name'],
'id' => $order->fields['customers_id'],
'company' => $order->fields['customers_company'],
'street_address' => $order->fields['customers_street_address'],
'suburb' => $order->fields['customers_suburb'],
'city' => $order->fields['customers_city'],
'postcode' => $order->fields['customers_postcode'],
'state' => $order->fields['customers_state'],
'country' => $order->fields['customers_country'],
'format_id' => $order->fields['customers_address_format_id'],
'telephone' => $order->fields['customers_telephone'],
'email_address' => $order->fields['customers_email_address']);
$this->delivery = array('name' => $order->fields['delivery_name'],
'company' => $order->fields['delivery_company'],
'street_address' => $order->fields['delivery_street_address'],
'suburb' => $order->fields['delivery_suburb'],
'city' => $order->fields['delivery_city'],
'postcode' => $order->fields['delivery_postcode'],
'state' => $order->fields['delivery_state'],
'country' => $order->fields['delivery_country'],
'format_id' => $order->fields['delivery_address_format_id']);
$this->billing = array('name' => $order->fields['billing_name'],
'company' => $order->fields['billing_company'],
'street_address' => $order->fields['billing_street_address'],
'suburb' => $order->fields['billing_suburb'],
'city' => $order->fields['billing_city'],
'postcode' => $order->fields['billing_postcode'],
'state' => $order->fields['billing_state'],
'country' => $order->fields['billing_country'],
'format_id' => $order->fields['billing_address_format_id']);
$index = 0;
// Removed the following and changed it with the one below to sort order the products on the invoices.
// $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 . "'");
//
$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 products_name");
// Changed above code AA TECH
while (!$orders_products->EOF) {
// convert quantity to proper decimals - account history
if (QUANTITY_DECIMALS != 0) {
$fix_qty = $orders_products->fields['products_quantity'];
switch (true) {
case (!strstr($fix_qty, '.')):
$new_qty = $fix_qty;
break;
default:
$new_qty = preg_replace('/[0]+$/', '', $orders_products->fields['products_quantity']);
break;
}
} else {
$new_qty = $orders_products->fields['products_quantity'];
}
$new_qty = round($new_qty, QUANTITY_DECIMALS);
if ($new_qty == (int)$new_qty) {
$new_qty = (int)$new_qty;
}
$this->products[$index] = array('qty' => $new_qty,
'id' => $orders_products->fields['products_id'],
'name' => $orders_products->fields['products_name'],
'model' => $orders_products->fields['products_model'],
'tax' => $orders_products->fields['products_tax'],
'price' => $orders_products->fields['products_price'],
'onetime_charges' => $orders_products->fields['onetime_charges'],
'final_price' => $orders_products->fields['final_price'],
'product_is_free' => $orders_products->fields['product_is_free']);
$subindex = 0;
$attributes = $db->Execute("select products_options, products_options_values, options_values_price,
price_prefix,
product_attribute_is_free
from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
where orders_id = '" . (int)$order_id . "'
and orders_products_id = '" . (int)$orders_products->fields['orders_products_id'] . "'");
if ($attributes->RecordCount()>0) {
while (!$attributes->EOF) {
$this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options'],
'value' => $attributes->fields['products_options_values'],
'prefix' => $attributes->fields['price_prefix'],
'price' => $attributes->fields['options_values_price'],
'product_attribute_is_free' =>$attributes->fields['product_attribute_is_free']);
$subindex++;
$attributes->MoveNext();
}
}
$index++;
$orders_products->MoveNext();
}
}
}
?>
New Zenner
Hy, i have managed to sort the products alphabeticaly in edit_orders.php also.
In admin/edit orders.php(your file may be different from mine!!!)
at line 904 change this code
$orders_products_query = $db -> Execute("select * from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$oID . "' ");
with this code
$orders_products_query = $db -> Execute("select * from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$oID . "' order by products_name");
IF THIS CODE IS NOT AT LINE 904 IN YOUR admin/edit_orders.php
SEARCH FOR THIS CODE BLOCK AND LOCATE THE LINE TO BE CHANGED
<!-- Begin Products Listings Block -->
<?php
// Override order.php Class's Field Limitations
$index = 0;
$order->products = array();
$orders_products_query = $db -> Execute("select * from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$oID . "'");
#while ($orders_products = zen_db_fetch_array($orders_products_query)) {
while (!$orders_products_query -> EOF){
$order->products[$index] = array('qty' => $orders_products_query->fields['products_quantity'],
'name' => zen_html_quotes($orders_products_query->fields['products_name']),
'model' => zen_html_quotes($orders_products_query->fields['products_model']),
'tax' => $orders_products_query->fields['products_tax'],
'price' => $orders_products_query->fields['products_price'],
'final_price' => $orders_products_query->fields['final_price'],
'orders_products_id' => $orders_products_query->fields['orders_products_id']);
:clap:this trick did the job for me.:clap:
Thanks to totaalteller
New Zenner
Thank you very much... You Are right... This did it. Very well posted and detailed.
New Zenner
Thanks to the information in this thread I have been able to sort the packing slip based on the product name...by modifying the file: admin\includes\classes\order.php. Consequently when I am preparing orders I am able to see the list of items ordered alphabetically.
The customer, however, still sees the items ordered in the order he placed them in his cart at the time he checks out and also at the time he receives his order confirmation.
Consequently I wonder if someone could direct me to the proper place to make the changes so that the shopping cart and order confirmation are also showing the items by name rather than by date/time.
Thanks
New Zenner
I have the exact same request as maineiac13 above.
It would be great to be able to print a packing slip directly from the confirmation e-mail, but as it is that still shows up in the order the items where placed in the cart.
New Zenner
yes - good option.......any info on how to do this.?
New Zenner
totaalteller:
\admin\includes\classes\order.php
this is the original 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");
>
> change ```
order by orders_products_id
``` to ```
order by products_model
Thanks to the above post I was able to sort my invoices according to alphabetical order. I often need to change the order and its not practical for me to be changing the model name every time the order needs to be changed.
Is there some other variable that I can sort according to like products_tax or some other variable?
Thank you in advance.
New Zenner
Let me make my question simpler. How do I sort the invoice based on manufacturers name?
Thanks again.
Tell staff why this post should be reviewed.