In an uc Order tpl template this one outputs all the attributes in that array.

<?php foreach ($product->data['attributes'] as $attribute => $option) {
   echo
'<li>'. t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array)$option))) .'</li>';
}
?>

[products] => Array
    (
        [0] => stdClass Object
            (
                [data] => Array
                    (
                        [attributes] => Array
                            (
                                [Color] => Array
                                    (
                                        [4] => Red
                                    )

                                [Size] => Array
                                    (
                                        [0] => M
                                    )

                                [Variants] => Array
                                    (
                                        [0] => abc123456
                                    )
                            )
                    )
            )

    )

But I only want to print the size and color attributes and exclude variants from the result.

I was expecting that I am able to print the attributes one by one like this.
<?php echo($product->data['attributes']['size']); ?>
To my dismay, it didn't work.

Comments

$product[0]->data['attributes

$product[0]->data['attributes']['Size'][0]

Jaypan We build websites

Ok thanks. But only worked

Ok thanks. But only worked for textfield types. I have a select list type and couldn't properly referenced the index using that. Here's what I came up though. Since attributes is an array as well I combined all the values of the array separated with commas.
<?php echo(implode(',', (array)$product->data['attributes']['Size'])); ?>

nobody click here