Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Position Of Items In An Order Rate Topic   - - - - -

 
  • Soneritics
  • Newbie
  • Members
  • Join Date: 19-Jan 17
  • 10 posts

Posted 19 January 2017 - 07:05 PM #1

Hi,

 

One of my customers is creating manual orders as quotations. They send this to the customer, who can choose to accept the quotation and pay for this order online.

 

Now when a quotation is made, the order/position of items in the order is important. When a quotation contains 100 items, they must be grouped somehow. It is OK if they can use the position of items in the order for this.

 

Right now, an order sorts the items by their name. I have checked the source code for the query and the ORDER BY clause, but it can not be changed by using an addon/hook. Only when I change the shop's source code it can be changed, but then I can not automatically update anymore.

 

I would like to see a setting/switch where the shop owner can choose to order products by their name, or order them by the order in which the customer (or admin) added the products.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21793 posts

Posted 20 January 2017 - 07:23 AM #2


You can use the get_order_info hook in the fn_get_order_info function to sort $order['products'] array according to your needs
 


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • Soneritics
  • Newbie
  • Members
  • Join Date: 19-Jan 17
  • 10 posts

Posted 22 January 2017 - 10:54 AM #3

Thanks, however it's a little devious it's still very usable :)



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12044 posts

Posted 22 January 2017 - 09:09 PM #4

Thanks, however it's a little devious it's still very usable :)

What's devious?

 

Create a hook for get_order_info.  Add code to alter the order of the 'products' array as suits your needs.

If the issue is that you don't have the original order product entry order, then you'll need to add a separate hook that will capture that info and then store it and use it as "the order" later or simply do a query to get the order in the DB (I.e. without the ORDER BY) and re-sort according to that order.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Soneritics
  • Newbie
  • Members
  • Join Date: 19-Jan 17
  • 10 posts

Posted 23 January 2017 - 06:30 AM #5

Devious in the fact that in the fn_get_order_info function the $order['products'] array is the result of a database query, but after querying and filling the array a lot of extra information is added. So it is not a matter of simply updating the $order['products'] array.

 

It is to be solved by one of the following methods:

  1. Update the $order['products'] array with an updated database query. Then use the code from the fn_get_order_info function to add the extra information.
  2. Fetch the correct order from the database. Then reorder/rebuild the $order['products'] array.

Second option is the best imo.

 

Anyway, I'd rather have seen a hook earlier in the process, so I could eithel change the query or change the ORDER BY part.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12044 posts

Posted 23 January 2017 - 09:34 PM #6

You can always use a post controller instead of the hook.  This is processed after all the business logic and after all the template variables are set.  So you can retreive the 'order_info' template variable, adjust it to your needs, then reapply it to the $order_info variable.

 

This is one of the oldest hooks.  Most of the primary functions now have a [function_name]_pre (before DB query) and a [function_name]_post (before the function returns the data.  You can always request a new 'post' hook be added just before the array is returned.  There's a sticky post in the developers section to request new hooks.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.