Saturday, October 2, 2010

PrestaShop Tips - How to change address displaying format (Back office)

At PrestaShop, the addresses are default displayed in Europe address format. They look weird for some other country's addresses for example in USA or Canada. Here I explain on how to change the address display format for USA/Canada. I separate them into front store and back office, so it will be in two posts.

Please click here to see how to change address displaying format for front store pages

Here is my second post on how to change PrstaShop address displaying format at back office and PDF invoices and PDF delivery slip. For your reference, I attached comparison screen of files before/after change.

1. ./admin/tabs/AdminOrders.php
Replace line 584,585 with following lines

'.$addressDelivery->city.($addressDelivery->id_state ? ' '.$deliveryState->name : '').' '.$addressDelivery->postcode.'<br />
'.$addressDelivery->country.'<br />
'.(!empty($addressDelivery->phone) ? $addressDelivery->phone.'<br />' : '').'
'.(!empty($addressDelivery->phone_mobile) ? $addressDelivery->phone_mobile.'<br />' : '').'


Replace line 595,596 with following lines

'.$addressInvoice->city.($addressInvoice->id_state ? ' '.$invoiceState->name : '').' '.$addressInvoice->postcode.'<br />
'.$addressInvoice->country.'<br />
'.(!empty($addressInvoice->phone) ? $addressInvoice->phone.'<br />' : '').'
'.(!empty($addressInvoice->phone_mobile) ? $addressInvoice->phone_mobile.'<br />' : '').'


These changes will change address displaying format to USA/Canada address format at order detail pages. Both shipping address and billing address of order will be displayed correctly.


2. ./classes/PDF.php
Replace line 409 -


$pdf->Cell($width, 10, $delivery_address->city.', '.Tools::iconv('utf-8', self::encoding(), ($deliveryState ? ''.$deliveryState->name : '')).', ' .Tools::iconv('utf-8', self::encoding(), $delivery_address->postcode), 0, 'L');
$pdf->Cell($width, 10, $invoice_address->city.', '.Tools::iconv('utf-8', self::encoding(), ($invoiceState ? ''.$invoiceState->name : '')).', ' .Tools::iconv('utf-8', self::encoding(), $invoice_address->postcode), 0, 'L');
$pdf->Ln(5);
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->country), 0, 'L');
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->country), 0, 'L');


These changes will change address displaying format to USA/Canada address format at PDF invoice and PDF delivery slip. Both shipping address and billing address of order will be displayed correctly.

No comments: