Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fatal Error When Using Product With Atrributes


celluloidsnake

Recommended Posts

Posted

Hi there,

 

I am using 2.2 MS-2 and have today started using attributes. I have never in the past had any need but after many issues with the upload I finally got easy populate to put the 88 T-Shirts with sizes and colors as options. All seemed ok until I tried to add one to the cart and got the following error............

 

11rxi8i.jpg

 

Fatal error: Call to a member function calculate_price() on a non-object in /home/uk2usa/public_html/includes/classes/shopping_cart.php on line 398

 

The error is there until you clear cookies and everything is removed from your cart.

 

I have had a look at line 399 but I am quite new to PHP and couldnt see anything that would throw it out in there.

 

Here is the code from line 382-430 which seems to mention the atributes and options a great deal...........

 

			 // substitute options_values_price and prefix for those for the customer group (if available)
		 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
		    for ($n = 0 ; $n < count($attribute_price); $n++) {
			 for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
				 if ($cg_attr_prices[$i]['products_attributes_id'] == $attribute_price[$n]['products_attributes_id']) {
					$attribute_price[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
					$attribute_price[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
				 }
			 } // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
	          }
	        } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
	      } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
	// now loop through array $attribute_price to add up/substract attribute prices

	   for ($n = 0 ; $n < count($attribute_price); $n++) {
	            if ($attribute_price[$n]['price_prefix'] == '+') {
	              $this->total += $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty);
	            } else {
	              $this->total -= $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty);
	        }
	   } // end for ($n = 0 ; $n < count($attribute_price); $n++)
	          } // end if (tep_db_num_rows($attribute_price_query))
	        } // end if (isset($this->contents[$products_id]['attributes'])) 
	      }
	    }
	// EOF SPPC attributes mod

   	// function attributes_price changed partially according to FalseDawn's post
	// http://www.oscommerce.com/forums/index.php?showtopic=139587
	// changed completely for Separate Pricing Per Customer, attributes mod
	    function attributes_price($products_id) {
	// global variable (session) $sppc_customer_group_id -> class variable cg_id
	    $this->cg_id = $this->get_customer_group_id();

	      if (isset($this->contents[$products_id]['attributes'])) {
	        reset($this->contents[$products_id]['attributes']);
	       $where = " AND ((";
	        while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
	         $where .= "options_id = '" . (int)$option . "' AND options_values_id = '" . (int)$value . "') OR (";
	       }
	       $where=substr($where, 0, -5) . ')';

	       $attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where ."");

	      if (tep_db_num_rows($attribute_price_query)) {
		       $list_of_prdcts_attributes_id = '';
		       while ($attributes_price_array = tep_db_fetch_array($attribute_price_query)) { 
			   $attribute_price[] =  $attributes_price_array;
			   $list_of_prdcts_attributes_id .= $attributes_price_array['products_attributes_id'].",";
	          }

 

Any help on this would be greatly appreciated. When I have mastered PHP myself I will most assuredly repay the favor to the forum as I do on a number of graphic design forums.

 

Thanks in advance.

Posted

WOW! I have only just noticed that the code on my site actually has references to this site in it. That really threw me. I thought I had somehow pasted something from the site without noticing.

Posted

 

 

The error is saying $attribute_price[$n]['options_values_price'], is not set, you need to find why.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...