Pregunta

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?!

¿Fue útil?

Solución

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.

Otros consejos

There are 2 ways to get the customer taxvat number from order

1. $order->getData('customer_taxvat')
2. $order->getQuote->getCustomerTaxVat();

I used below code to get the customer tax/vat. It is properly working for me.

Vat Number: {{var order.getCustomerTaxvat()}}

in sales order email template.

Right: Vat Number: {{var order.getCustomerTaxvat()}}

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top