Hello,
I wonder if there is any way to show out of stock items at the end of category?
Have you tried searching the forums or looking at the code itself?
Only spent a few minutes on this, so there might be a more sensible place to make the edit, or this edit might be a bad one, but I gave it a very quick test and it seemed to work (only tried the first part of the IF, it would be easy enough to modify the other parts):
The problem with sorting by a product's stock status is that stock status can have multiple values, so you'll need to decide what order you want all of them to appear in - and to remember to update the script if you ever modify the available stock status options.
Only spent a few minutes on this, so there might be a more sensible place to make the edit, or this edit might be a bad one, but I gave it a very quick test and it seemed to work (only tried the first part of the IF, it would be easy enough to modify the other parts):
Code: Select all
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
// Original
// $sql .= " ORDER BY LCASE(" . $data['sort'] . ")";
// Quantity
// $sql .= " ORDER BY IF(quantity<1,1,0),LCASE(" . $data['sort'] . ")";
// Stock status
$sql .= " ORDER BY CASE
WHEN stock_status_id = 7 THEN 0 -- In Stock
WHEN stock_status_id = 8 THEN 1 -- Pre-order
WHEN stock_status_id = 6 THEN 2 -- 2 - 3 Days
WHEN stock_status_id = 5 THEN 3 -- Out of Stock
END,LCASE(" . $data['sort'] . ")";
} elseif ($data['sort'] == 'p.price') {
$sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)";
} else {
$sql .= " ORDER BY " . $data['sort'];
}
} else {
$sql .= " ORDER BY p.sort_order";
}
hello, does this work on v2.1.0.1? where it needs to be placed?ogun wrote: ↑Thu Jun 13, 2013 5:10 pmHave you tried searching the forums or looking at the code itself?
Only spent a few minutes on this, so there might be a more sensible place to make the edit, or this edit might be a bad one, but I gave it a very quick test and it seemed to work (only tried the first part of the IF, it would be easy enough to modify the other parts):The problem with sorting by a product's stock status is that stock status can have multiple values, so you'll need to decide what order you want all of them to appear in - and to remember to update the script if you ever modify the available stock status options.Code: Select all
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') { // Original // $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; // Quantity // $sql .= " ORDER BY IF(quantity<1,1,0),LCASE(" . $data['sort'] . ")"; // Stock status $sql .= " ORDER BY CASE WHEN stock_status_id = 7 THEN 0 -- In Stock WHEN stock_status_id = 8 THEN 1 -- Pre-order WHEN stock_status_id = 6 THEN 2 -- 2 - 3 Days WHEN stock_status_id = 5 THEN 3 -- Out of Stock END,LCASE(" . $data['sort'] . ")"; } elseif ($data['sort'] == 'p.price') { $sql .= " ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount ELSE p.price END)"; } else { $sql .= " ORDER BY " . $data['sort']; } } else { $sql .= " ORDER BY p.sort_order"; }
You want something like this?
https://www.opencart.com/index.php?rout ... n_id=23095
https://www.opencart.com/index.php?rout ... n_id=23095
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
Hello, no, I want to sort catalog by product_stock_id where all products out of stock will be at the end, then 15days, then preorder and at the top in stock products.xxvirusxx wrote: ↑Fri Jun 21, 2019 9:14 pmYou want something like this?
https://www.opencart.com/index.php?rout ... n_id=23095
So you just post in another topic with title...Display out of stock items at the end of category and you want something else....
Next time don't post in another topic if isn't that you need.
Try to post on Commercial section and pay a developer.
viewforum.php?f=88
Next time don't post in another topic if isn't that you need.
Try to post on Commercial section and pay a developer.
viewforum.php?f=88
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
Who is online
Users browsing this forum: No registered users and 337 guests