Post by chancaarke » Thu Apr 12, 2018 3:59 pm

Hi,

... using Opencast 1.5.6.4...
When I print my invoices, I simply would like to sort the products alphabetically by the value of the "Location" field.
I suppose I will have to change it in the template on "admin/view/template/sale/order_invoice.tpl"...

The array of the products within an order needs to be ordered by "Location" before the start of the echo of each product field in the loop, right?
So, before starting by " <?php foreach ($order['product'] as $product) { ?>"

Hoping to see a reply ;)

Newbie

Posts

Joined
Thu Apr 12, 2018 3:45 pm

Post by straightlight » Fri Apr 13, 2018 1:37 am

The only problem is that the location is not copied into the order products but only remains in the store. It can still be pulled but what happens if the product ID from the order products can no longer be tracked from the store?

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com contractor officials representative


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by chancaarke » Fri Apr 13, 2018 8:13 am

Hi Straightlight, thanks for your quick reply!

The first thing I did was adding the 'location' element for the product array.
Therefore I added next things in the file "admin/controller/sale/order.php":

// >>> more or less on line 1642, within "foreach ($products as $product)"
$query = $this->db->query("SELECT location FROM " . DB_PREFIX . "product WHERE product_id = '" . $product['product_id'] . "'");
$product['location'] = $query->row['location'];

// >>> more or less on line 2503, also within "foreach ($products as $product)"
$query = $this->db->query("SELECT location FROM " . DB_PREFIX . "product WHERE product_id = '" . $product['product_id'] . "'");
$product['location'] = $query->row['location'];

// >>> more or less on line 2520, adding the element 'location' for $product_data[] = array(...
'location' => $product['location'],

So, from now on I can use the location value product['location'] in "admin/view/template/sale/order_invoice.tpl".
I suppose the products are ordered by "product id" by default on the invoice (which I also use as my packing slip).
As my products picking is organized by an alphabetically sorted location in my warehouse, my question is:

2 questions:

1.) You said: "It can still be pulled but what happens if the product ID from the order products can no longer be tracked from the store?" What dos you mean and when can that happen?
2.) How/Where can I change the order of the items (products), alphabetically ordered by 'Location'i order to optimize my workflow?

Newbie

Posts

Joined
Thu Apr 12, 2018 3:45 pm

Post by straightlight » Fri Apr 13, 2018 9:06 am

What dos you mean and when can that happen?
By administrative decision. One day, an admin user could get rid of one product which this product has been ordered but can no longer be referenced from the order products to call that particular product from the store since it would be removed prior. How would you be able to re-track its location?

Although, the query itself above is valid. It's just missing the concept on knowing what would happen if the product no longer exist from the store.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com contractor officials representative


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by chancaarke » Fri Apr 13, 2018 9:34 am

Ok, I see. Well, I'm not worried about the fact a product won't exist anymore. We simply print the invoice or mail the pdf version at that moment when the product exists.

Can you please help me with ordering the array to sort by location before the start of the echo commands in next loop in the invoice starting by
<?php foreach ($order['product'] as $product) { ?>

Newbie

Posts

Joined
Thu Apr 12, 2018 3:45 pm
Who is online

Users browsing this forum: No registered users and 13 guests