In the old versions of opencart he sorted the moment of placing the product in the shopping cart. In version 3.x it sorts by id. How can I get this back in such a way that he will see the moment of putting the items in the shopping cart as the sorting order.
So not by model or product ID
So not by model or product ID
Last edited by k2tec on Tue Jan 17, 2023 2:47 am, edited 2 times in total.
It doesn't really sort it by anything. But you can add ORDER BY date_added to getProducts() function in system/library/cart/cart.php file.
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
Hi thekrotek,
THanks for your reply. The order by date won't help I have read that post.
In all the old shops 1.4. and 2.0.1 the products are sort by putting them in to the basket. Maybe the sessions setting are different in the old shops.
THanks for your reply. The order by date won't help I have read that post.
In all the old shops 1.4. and 2.0.1 the products are sort by putting them in to the basket. Maybe the sessions setting are different in the old shops.
OpenCart before 2.1 saved the cart in the session. For 2.1 and above the cart is stored in the database, so the order is defined by the database and the query. Why do you think adding ORDER BY date_added to the queries won't work?
Thanks for the reply, I will look at it tomorrow. But it is not the moment of ordering.
Suppose I want to assemble a chimney from 4 products and then I also order 10 parts for electricity. Now they all get mixed up and is a bit more complicated with orderpick with big orders
Suppose I want to assemble a chimney from 4 products and then I also order 10 parts for electricity. Now they all get mixed up and is a bit more complicated with orderpick with big orders
There might be a table you can sort by e.g. the ID of oc_cart.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Are you looking to change the order of the products in the cart or are you actually looking to change the order of the products on the order?
If it's the latter this may help.
viewtopic.php?f=202&p=846766
If it's the latter this may help.
viewtopic.php?f=202&p=846766
Thanks all for the replies. I tried this one
To this
Places everything beautiful in the cart and even in the checkout it is the right sorting, but in the written sales order in admin the sort order is not right any more.
Code: Select all
cart_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "'");
Code: Select all
cart_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "' ORDER BY cart_id ");
Have a look in the oc_order_product table for an order made after you changed. Are the products in the correct order?
If they are you may be able, in getOrderProducts(), to sort by the order_product_id comum which auto increments.
If they are you may be able, in getOrderProducts(), to sort by the order_product_id comum which auto increments.
That did the job ADD Creative
Thanks all for your help.
This is what I changed in admin>model> sale>order.php
into
In the system/library/cart/cart.php
into
This makes it a lot easier for order picking
Thanks all for your help.
This is what I changed in admin>model> sale>order.php
Code: Select all
public function getOrderProducts($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
return $query->rows;
}
Code: Select all
public function getOrderProducts($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "' ORDER BY order_product_id");
return $query->rows;
}
Code: Select all
cart_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "'");
Code: Select all
cart_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "' ORDER BY cart_id ");
Who is online
Users browsing this forum: Google [Bot] and 111 guests