A2 Hosting
General support for technical problems with OpenCart v2.x
4 posts Page 1 of 1
by Keejos » Tue Jan 10, 2017 3:55 am

Tried to search for help on this but couldn't find it, forgive me if its been asked before.
I'm looking for a way to let the shopping cart display the items sorted by item name (A-Z).

I run a photography webshop, where clients get to choose from in between 50-100 different pictures after a shoot. Right now it sorts by 'date+time added', instead of by item name. As a result, shopping cart looks like:


Would it at ALL be possible to change this to sort by name? Ideally I would like to have clients be able to pick their own type of sort order as they please (by clicking column names), but for now let's focus on getting the items in shopping cart sorted A-Z by item name.

Thank you so so much!

by opencartmart » Tue Jan 10, 2017 8:20 pm
What is your OC version exactly?

by Keejos » Thu Jan 12, 2017 4:54 am
It's :)
by opencartmart » Thu Jan 12, 2017 9:45 pm
In the file system/library/cart/cart.php, find the function getProducts() and add following lines of code just before the last line i.e. return $product_data;

Code: Select all
              $name_order = array();
      foreach ($product_data as $key => $value) {
         $name_order[$key] = $value['name'];
       $name_order = array_map('strtolower', $name_order);
       array_multisort($name_order, SORT_ASC, $product_data);
4 posts Page 1 of 1
Who is online

Users browsing this forum: gossamerLL and 24 guests

A2 Hosting