AbanteCart Community

eCommerce construction => How-to questions => Topic started by: potangina on March 06, 2018, 11:03:21 AM

Title: Sort items in cart according to price
Post by: potangina on March 06, 2018, 11:03:21 AM
Hello! how can i sort items in the cart according to price?
Title: Re: Sort items in cart according to price
Post by: abantecart on March 06, 2018, 06:40:45 PM
A little more details would be helpful.

I assume you refer to shopping cart page.
Are you looking to sort the display permanently or offer option to sort product in the shopping cart page?

In case of sorting permanently you can use PHP sorting in this file (before line 270):
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/pages/checkout/cart.php#L270

Sort array $cart_products by key 'price'. If you need to sort including tax, you would need to add tax calculation prior to sorting
Title: Re: Sort items in cart according to price
Post by: potangina on March 06, 2018, 10:13:39 PM
thanks for the quick response and sorry for the inadequate info i provided, yes, i was referring to the shopping cart page as well as the cart that appears when you hover over the "ITEMS" button at the storefront homepage.