Display customer TAX / VAT number

SPRBRN picture SPRBRN · Apr 17, 2013 · Viewed 11.1k times · Source

I want to display the VAT number of the customer in the invoice PDF. I've found several methods online that describe this, but they all don't seem to work for my installation, Magento 1.7.0.2. It should work for registered customers and guests as well. I've found the following two solutions, which don't work:

$taxvat = $order->getData('customer_taxvat'); // does not work
$taxvat = $order->getData('vat_id'); // does not work

Then I decided to use var_dump('$order') and it showd the VAT number. So using the following code I can display it in the PDF, but I don't know if this can cause problems.

$taxvat = $order['customer_taxvat']; // WORKS!

I would prefer to use the Magento way, but how?!

Answer

Supriti Panda picture Supriti Panda · Apr 18, 2013

Looks like the $order you are using is an array and not an object. So your following code doesn't work.

$order->getData('customer_taxvat');

If your $order is an object then the above code will work.