Hi, first of all thanks for this great open script. These past weeks I've been modding my Open Cart installation to suit my specific needs, but I found no answer to this:
Is there a way to hide products (from Category list, search results or anywhere else) wich were already added to the cart?
That's because I want to run a store with thounsands of unique items. So all the products will have a "1" quantity and it will be much less confusing for the customer not to see again the products he already "purchased".
Best regards and thanks in advance!
It is possible but not as a store configuration option. You will have to change some of the code.
On each of the controllers that get product data to display on a page, you will have to remove any items that have been selected in the shopping cart ( $cart->getProducts() ) from the $results array returned by the "normal" query.
On each of the controllers that get product data to display on a page, you will have to remove any items that have been selected in the shopping cart ( $cart->getProducts() ) from the $results array returned by the "normal" query.
Hi Bruce! Thanks so much for your answer. I'm not a coder, though, so I don't know how to do that (but I understand the logics behind your idea).
By the way, I've already been playing with the category controller and added the p.quantity > 0 just as you mentioned here:
http://forum.opencart.com/index.php/topic,950.0.html
I discovered from that that the stock is modified only after the checkout process. That's why I needed another solution to hide the products which are in the cart.
My $results in the category controller now reads like this:
Please, can you tell me how can I correctly implement the $cart->getProducts() trick within this controller?
I'll be really grateful. Thank you very much for your time and best regards.
By the way, I've already been playing with the category controller and added the p.quantity > 0 just as you mentioned here:
http://forum.opencart.com/index.php/topic,950.0.html
I discovered from that that the stock is modified only after the checkout process. That's why I needed another solution to hide the products which are in the cart.
My $results in the category controller now reads like this:
Code: Select all
$results = $database->getRows($database->splitQuery("select * from product p left join product_description pd on (p.product_id = pd.product_id) left join product_to_category p2c on (p.product_id = p2c.product_id) left join image i on (p.image_id = i.image_id) where status = '1' and language_id = '" . (int)$language->getId() . "' and p2c.category_id = '" . (int)end(explode('_', $request->get('path'))) . "' and p.date_available < now() and p.status = '1' and p.quantity > 0 order by p.sort_order, pd.name", ($request->has('path') ? $session->get('category.' . $request->get('path') . '.page') : $session->get('category.page')), $config->get('config_max_rows')));
I'll be really grateful. Thank you very much for your time and best regards.
Ok, for the category controller...
add the following to the top of the index() function along with the other similar declarations.
under the product results line put the following. Note that I have replaced unrelated code elements with ...
You should be able to duplicate this process in the Latest/Featured/Specials modules if you want to.
Cheers
Bruce
add the following to the top of the index() function along with the other similar declarations.
Code: Select all
$cart =& $this->locator->get('cart');
Code: Select all
$results = ...
// experiment
$cart_products = $cart->getProducts();
$cart_product_ids = array();
foreach ($cart_products as $prod)
{
// get just the productID's
$cart_product_ids[] = $prod['product_id'];
}
foreach ($results as $result)
{
...
// if the product is not in the cart, allow it into the final result set.
if (!in_array($result['product_id'], $cart_product_ids))
{
$product_data[] = array(
...
);
}
}
Cheers
Bruce
Who is online
Users browsing this forum: No registered users and 4 guests