Jump to content

Matching data in an array


woza

Recommended Posts

Hi everyone

 

I wondered if anyone could help me out with some code for a Zen Cart site I run.

Basically I wanted to create a script so when someone add's an item to the cart the shopping cart button changes from "add to cart" to "add another".

I managed to find out Zen Cart stores cart info in a array, which has the product id so I created the below script:

 

if ($_SESSION['cart']->in_cart($_GET['products_id'])) {  $BUTTONIMAGEINCART = 'cart/button_in_cart_5b.png'; } else { $BUTTONIMAGEINCART = 'cart/button_in_cart_5.png';}

 

This seem to work fine until I noticed it didn't work for all products. So I checked the contents of the array and found for some strange reason zen cart adds a session id after the product id. So instead of

 

Array ( [id] => 1841 ....

 

It puts:

 

Array ( [id] => 1477:a4e70f439369b7abdecbcb784aa75ba7 ....

 

which stops my method from working.

 

Does any know how I can get around this. Either by stripping off the id in array or getting it to read only the part before the : ?

 

Any help would be greatly appreciated.

 

Many thanks

 

Warren

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.