Welcome Guest, Not a member yet? Register   Sign In
Check if item added to cart or not.
#1

[eluser]ahandy[/eluser]
Hi.

I was wondering if there was any way I could check if the item has already been added to the cart or not?
#2

[eluser]InsiteFX[/eluser]
Maybe the carts $contents

InsiteFX
#3

[eluser]ahandy[/eluser]
I've been trying, but I just can't get it right. Any idea on how to do it EXACTLY?
#4

[eluser]ahandy[/eluser]
I fixed it. To anyone wondering how:

[code]
function in_multiarray($elem, $array)
{
// if the $array is an array or is an object
if( is_array( $array ) || is_object( $array ) )
{
// if $elem is in $array object
if( is_object( $array ) )
{
$temp_array = get_object_vars( $array );
if( in_array( $elem, $temp_array ) )
return TRUE;
}

// if $elem is in $array return true
if( is_array( $array ) && in_array( $elem, $array ) )
return TRUE;


// if $elem isn't in $array, then check foreach element
foreach( $array as $array_element )
{
// if $array_element is an array or is an object call the in_multiarray function to this element
// if in_multiarray returns TRUE, than return is in array, else check next element
if( ( is_array( $array_element ) || is_object( $array_element ) ) && $this->in_multiarray( $elem, $array_element ) )
{
return TRUE;
exit;
}
}
}

// if isn't in array return FALSE
return FALSE;
}
[/php]

I used that from php.net and worked through it.




Theme © iAndrew 2016 - Forum software by © MyBB