Order Products Print on Invoice?

  • Posts: 5
  • Thank you received: 0
13 years 9 months ago #7067

Can I change the order that the products print on the invoice?

What order are they in?

Thanks,

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 9 months ago #7075

There is no particular order, so it's kind of random based on your mysql database engine decision.

You can always edit the file where the query is made to load the products if you want to change it.
But what order would you like to have ? Is there any reason ?

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
13 years 9 months ago #7098

Thank you for your quick reply and also thank you for the great product.

What we are doing is using this module to sell registrations to an event. We also sell add-ons like lunches and patches. (These are Girl Scouts.)

We would like the registration product itself to appear on the invoice first following by any of the add-ons. If I could sort by product_id or anything I could make it work.

It's only on the actual invoice form that it matters. Is that the file where I would query the database? I'm sorry but my php skills, while growing daily, are severely limited. But I am willing to learn anything. If you could just point me to the right file and right direction I could probably figure it out eventually.

Thanks again.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 9 months ago #7099

The query which loads the products of the order is located in the file administrator/components/com_hikashop/classes/order.php in the function loadProducts. There, you can change the line:
$query = 'SELECT a.* FROM '.hikashop::table('order_product').' AS a WHERE a.order_id = '.$order->order_id;
to:
$query = 'SELECT a.* FROM '.hikashop::table('order_product').' AS a WHERE a.order_id = '.$order->order_id.' ORDER BY product_id';

Please note that when you update hikashop, this modification will be lost so you will have to reapply it.

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
13 years 9 months ago #7115

Thank you so much for the quick answer and the code!

I did get it working but it was quite the learning process for me as I thought I would be clever and go into the SQL products database and edit product_id codes directly. After several hours of relating everything correctly again as obviously by doing that I messed up a lot of cross-references, I'm back in business and everything is working again.

But here are a couple of questions.

Is there any documentation anywhere that shows how all the files relate to each other?

and

How do the image files relate to the product files? I lost all my images when I renumbered my product id, so obviously I wasn't updating something somewhere.

And was there another way I could have renamed my product ids without going directly to the database?

But bottomline, it is all working now the way we needed it to work and are very grateful for this great product and quick responses to questions.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 9 months ago #7120

Changing the product_id is really not a good idea as all the other tables related to products use that id for reference.

If you want to sort your products easily, you should use another field. There are not much fields in the order_product table but you could use the product code. So, in your products, you could set the code of products, and then, instead of having ORDER BY product_id in that query, you could have ORDER BY order_product_code. That way, you don't even need to touch the database.

the files and images of products are all referenced in the hikashp_file table. The file_ref_id in combination with the file_type is used to determine which file is for which product and for which purpose (image or file). There is no global schema of the structure of HikaShop.

Please Log in or Create an account to join the conversation.

Time to create page: 0.062 seconds
Powered by Kunena Forum