I have an Ubercart commerce website in Drupal 7.
I'm trying to sort the products listed inside a given completed order by the SKU value.
This is the link: /admin/store/orders/1 or /admin/store/orders/300
I tried to edit uc-order--admin.tpl.php but it did not work. I tried everything but nothing works. Maybe I'm doing it wrong.
I'm new to theming and templating so the code I wrote or the place I did might have been wrong also.
Any ideas on how to sort the products by the values in the SKU field in an order that was already placed?
Inside uc-order--admin.tpl.php
I added the following code:
$order_output = array(); $order_info = new stdClass(); $order_id = ''; $array_key_modifier = 0; foreach ($products as $product) { // organize products by sku // make an array with stuff I need // sku => array(item,model,price,quantity,subtotal) // then sort keys by alphabetical value, output to table $array_key = ''; if (!isset($order_output[$product->model])) { $array_key = $product->model; } else { $array_key = $product->model . $array_key_modifier; $array_key_modifier++; } $order_output[$array_key] = array("title" => $product->title, "model" => $product->model, "price" => $product->price, "quantity" => $product->qty, "subtotal" => $product->total_price); // "price"); $order_info = $product->order; // each product has complete built in order info. Maintain a reference to it $order_id = $product->order_id; if (!empty($product->data['attributes'])): $order_output[$array_key]["attributes"] = $product->data['attributes']; endif; } ksort($order_output);
the code I wrote or the place I did might have been wrong
– What code at what place? Please edit that into your question. Many thanks