Forums / Developer / Shop Donation / Comment46903

Author Topic

Rob Borley

Tuesday 13 February 2007 3:37:51 am

Comment46903

David, This isn't a straight forward as Kracker wants to make out (as the lack of response to this post only shows). Or at least, if it is I've missed the point and would really appreciate his knowledge.

I decided that the approach to take was to create a new DataType and then allow the addToBasket function to use it.

However, I couldn't work out how to do that.

So I decided to use the ezinteger as I'm not using it in any other classes.

The code for the addToBasket function i ended up with was as follows

 foreach ( $attributes as $attribute )
        {
            $dataType = $attribute->dataType();
            if ( eZShopFunctions::isProductDatatype( $dataType->isA() ) )
            {
                $priceObj =& $attribute->content();
                //$price += $priceObj->attribute( 'price' );
                //$priceFound = true;
                
                			if (array_key_exists('price', $priceObj)) {
 						$price += $priceObj('price');
 						$priceFound = true;
					} elseif (array_key_exists('integer', $priceObj)){
  						$price += $priceObj('integer');
  						$priceFound = true;
					} else {
					$priceFound = false;
					
					}
                
                
            }

I got this far and realised that attribute is actually a function and so the debug is returning the following error.

array_key_exists(): The second argument should be either an array or an object in

So I thought I'd dig out the attribute function and have a hack around with that.

Only problem is I can't find it!!!!

Please, somebody, anybody, put me out of my misery.