0

I have this $order object, where I would like to access e.g. shipping_name, but, just can't seem to figure it out. Tried $order->shipping[0]['shipping_name'] +++

UPDATE: $order->weight would give me 3, but $order->shipping returns nothing

Any help would be greatly appreciated

       [volume] => 0
        [weight] => 3
        [total_quantity] => 1
        [volume_unit] => m
        [weight_unit] => kg
        [shipping] => Array
            (
                [0] => stdClass Object
                    (
                        [code] => 95621
                        [shipping_currency_id] => 47
                        [countries] => DK
                        [postal_code] => 8410
                        [shipping_name] => GLS Pakkeshop - Circle K
                        [shipping_type] => gls
                        [shipping_id] => GLS - 362 - PAKKESHOP: 95621
                        [shipping_price] => 11.00000
                        [shipping_description] => 95621 Circle K Hovedgaden 74, 8410 
                        [shipping_address] => stdClass Object
                            (
                                [address_city] => Hovedgaden 74
                            )

                        [shipping_warehouse_id] => 0
                        [shipping_price_with_tax] => 11.00000
                        [shipping_price_orig_with_tax] => 
                    )

            )
Dyvel
  • 847
  • 1
  • 8
  • 20

2 Answers2

0

I suspect you want $order->shipping[0]->shipping_name because the [0] item in the array is an object.

It's an object containing an array of objects.

adfaklsdjf
  • 250
  • 1
  • 11
0

Try $order->shipping[0]->shipping_name.

When you have array, you can access it with ['key']. But when you have an object, you can access in it with $object->key

Héctor Prats
  • 273
  • 3
  • 14