Jump to content



- - - - -

Changing Buynow button background if product is in cart. Need help!


This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1   neolith

neolith
  • Members
  • 2 posts

Posted 19 May 2012 - 12:56 PM

I am trying to make a change of button "buy_now" background image if product is in cart. For example: all "buy_now" buttons have image1.png as a background by default. When customer clicks on any product "buy_now" button this image changes to image2.png and keep appearing as image2.png untill customer will remove this item from cart. I know that i need to make function which will compare concrete product ID with product ID storred in session in Database. But I don't know how to do that as my knowlege in PHP is very weak.
For now I modified code in product_listing_col.php like that:
if ($new_products_id_in_cart == $listing[$i]['id']){
			$lc_text .= '';
			$lc_text .= '<a class="buttton2" href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'], 'NONSSL') . '">' . '</a>';
		  }
		  else
		   {
		   $lc_text .= '<a class="buttton" href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'], 'NONSSL') . '">' ;
		  }

With this modification I have a successfull  button image change event, but after clicking any other "buy_now" button it reverts back to the first stage. So it works only for one item in a time.

Could anyone advice how to modify code to make "if" compare $listing[$i]['id'] with product_id wich is storred in current session?