Product sorting in cart

  • Posts: 57
  • Thank you received: 2
13 years 2 weeks ago #34404

Hi,

the product sorting or ordering in both, product-cart and checkout-cart are arbitrary.
And after changing the quantity, everything will be resorted. This is very confusing.
Is there a possibility to sort this as the product listing?

Thanks,
Hans

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

  • Posts: 83103
  • Thank you received: 13414
  • MODERATOR
13 years 2 weeks ago #34463

Hi,

The products in the cart are sorted like that: The latest product added is the first one, the first product added is the latest one.
I think that it's how most of the shopping carts handle that.

It would be possible to sort the products the same way as listing by changing the line:
$query='SELECT b.*,c.* FROM '.hikashop_table('cart_product').' AS b LEFT JOIN '.hikashop_table('product').' AS c ON b.product_id=c.product_id WHERE '.implode(' AND ',$filters).' ORDER BY c.product_parent_id ASC,b.cart_product_modified ASC';

in the file administrator/components/com_hikashop/classes/cart.php but since it's a modification to the core of HikaShop, you will loose it when you update.

For example, to sort by product name, you could use that instead:
$query='SELECT b.*,c.* FROM '.hikashop_table('cart_product').' AS b LEFT JOIN '.hikashop_table('product').' AS c ON b.product_id=c.product_id WHERE '.implode(' AND ',$filters).' ORDER BY c.product_parent_id ASC,c.product_name ASC';

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

  • Posts: 57
  • Thank you received: 2
13 years 2 weeks ago #34466

Hi,

the sorting, you provide is ok, but I think, it should not change after an update of the quantity, because the product row is "hopping" away from the user focus and will be replaced by another one. And this is very confusing, don't you think?
Is there any way to change this?

Core modification is not my favourite because of the increasing update work...


Thanks!

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

  • Posts: 83103
  • Thank you received: 13414
  • MODERATOR
13 years 2 weeks ago #34471

Very confusing, not so much since you're the first one having an issue with it :)
But I recon that fact that the ordering changes when the quantity changes is strange.

You can change that by changing the line:
$query = 'UPDATE '.hikashop_table('cart_product').' SET cart_product_modified=\''.time().'\',cart_product_quantity='.(int)$quantity.' WHERE cart_product_id='.$cartContent[$id]->cart_product_id;

to:
$query = 'UPDATE '.hikashop_table('cart_product').' SET cart_product_quantity='.(int)$quantity.' WHERE cart_product_id='.$cartContent[$id]->cart_product_id;

in the file administrator/components/com_hikashop/classes/cart.php


We'll change that on our end too for next release.

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

  • Posts: 57
  • Thank you received: 2
13 years 2 weeks ago #34527

Hi nicolas,

|Very confusing, not so much since you're the first one having an issue with it

Maybe, because I am not using the product info page, only a product listing. And I could not get a total calculation on the listing, so the user has to do change the quantity in the cart


Anyway, it now works well.
Thanks!

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

Time to create page: 0.061 seconds
Powered by Kunena Forum