Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Need help interpreting some code


Recommended Posts

In the file, catalog/includes/classes/shopping_cart.php, there is a function, "add_cart" that has some code I cannot follow, and I would appreciate a little help. Here it is:


The third line of the function reads,

$products_id = tep_get_uprid($products_id, $attributes);

As I interpret it, tep_get_uprid() returns a string of the form,

"prid{option}value{option}value...", where prid is the original $products_id (an integer) and option/value are subarray elements from the attributes array. Here is my confusion - this new string value of $products_id is later used in the same function as though it is an integer (as a proper $products_id should be).


For example, later in the same function, the following code appears:

$this->contents[] = array($products_id);

$this->contents[$products_id] = array('qty' => $qty);


Later still in "add_cart", $products_id is used as a variable in SQL statements that insert records in the database. It is beyond me how a complicated string as above could be used in that way, instead of an integer. Nowhere else in OSC do I find $products_id used in this way.


I assume I am ignorant regarding some sort of array notation, but I am unable to find it in the PHP programming books I have (several). Would someone please educate me on this? Thanks in advance for your help.


Tim B.

Artisans of the Ironwork Guild

Link to comment
Share on other sites


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

  • Create New...