Author Topic: How to check if product is already in cart ?  (Read 5752 times)

zrtva

  • Beginner
  • *
  • Posts: 1
How to check if product is already in cart ?
« on: December 28, 2010, 20:58:54 pm »
I'm trying to hide Add to chart button if product is already added to cart. I'm trying to do it from flypage. Is there a way to check if product is already in cart?

fromsoft_pl

  • Beginner
  • *
  • Posts: 4
    • FROMSOFT Computer Systems
Re: How to check if product is already in cart ?
« Reply #1 on: December 29, 2010, 20:52:04 pm »
Yes, it's possible (and quite easy) if you are programmer. You need to change flypage template by adding additional loop to existing one which iterate through cart content and hide 'add to cart' button if product exists in it.
Because it's usually a short list it doesn't slow down displaying your flypage.
If you don't have experience in PHP programming you need to hire someone.
FROMSOFT Computer Systems
PHP, Joomla!, Virtuemart
http://fromsoft.pl

nickelas

  • Beginner
  • *
  • Posts: 21
Re: How to check if product is already in cart ?
« Reply #2 on: April 15, 2011, 17:49:18 pm »
Any pointers to where one can find the required variables / methods for checking if the current product is already added to the cart (on the flypage)?

hax

  • Beginner
  • *
  • Posts: 1
Re: How to check if product is already in cart ?
« Reply #3 on: September 19, 2013, 12:40:19 pm »
I wanted to indicate which products are already in the cart by adding a border to the image, so at the top of com_virtuemart/category/default.php

I added:

$array = unserialize($_SESSION['__vm']['vmcart']);
$totalHaxProducts=array();
foreach($array->products as $product){
array_push($totalHaxProducts,$product->virtuemart_product_id);
}


and then at the part where the product images are displayed:

<?
                      if(in_array($product->virtuemart_product_id,$totalHaxProducts)){
                        echo "style=\"border:3px solid #ff0000;\"";
                     }
                     ?> />   


hope that helps someone.