views:

10

answers:

1

Hi All,

I'm writing a custom module for one of my projects and I'm having a bit of an issue. What I'm trying to do is get a piece of data from uc_cart_get_contents() into a variable so that I can use it in a calculation:

Here's my var_export:

array ( )array ( 0 => stdClass::__set_state(array( 'cart_item_id' => '5', 'cart_id' => '1', 'nid' => '9', 'qty' => '10', 'changed' => '1287074120', 'data' => array ( 'attributes' => array ( 3 => '4', ), 'shippable' => '1', 'restrict_qty' => '0', 'module' => 'uc_product', ), 'title' => 'Chicago Canyon', 'vid' => '9', 'cost' => 1.16, 'price' => 11.16, 'weight' => 0, 'module' => 'uc_product', 'model' => 'chicago-canyon-p-card-p-env', )), )

But what if I want to put the model of each item in the cart into a variable, and based upon that variable adjust the item's price.

If it was an array I would do this:

$items= uc_cart_get_contents();

$model = $items[model];

but that doesn't work, it's a std class. I'm so so lost. Please help!

+1  A: 

If your asking how to access object propertiers you do so like this:

$model = $items->model;
prodigitalson
that doesn't seem to work. I tried it, but when I try to echo out the variable nothing comes out. But no error is thrown though.
MrMaksimize
MrMaksimize