I've installed the very helpful EA Design Free Invoice PDF extension and it's working a treat - except for one area.
The variables used in the editor are drawn from the backend, which means that
- The locale is taken from the backend setting, which means that I - working in English on a Japanese storefront - get the wrong language for country and region in addresses, and the wrong names for the payment method.
- The formatting set up in System>Config is ignored
I think I've tracked the fetching of the addresses down to the following bit of code deep in the Models folder
public function getTheAddresInfo()
{
$order = $this->getOrder();
$billingInfo = $order->getBillingAddress()->getFormated(true);
if ($order->getShippingAddress()) {
$shippingInfo = $order->getShippingAddress()->getFormated(true);
} else {
$shippingInfo = '';
}
$variables = array(
'billing_address' => array(
'value' => $billingInfo,
'label' => Mage::helper('sales')->__('Billing Address'),
),
'shipping_address' => array(
'value' => $shippingInfo,
'label' => Mage::helper('sales')->__('Shipping Address'),
)
);
The only other model I've found with similar content is in app/code/core/Mage/Customer/Model/Address/Abstract.php
/**
* @deprecated for public function format
*/
public function getFormated($html=false)
{
return $this->format($html ? 'html' : 'text');
//Mage::getModel('directory/country')->load($this->getCountryId())->formatAddress($this, $html);
}
public function format($type)
{
if(!($formatType = $this->getConfig()->getFormatByCode($type))
|| !$formatType->getRenderer()) {
return null;
}
Mage::dispatchEvent('customer_address_format', array('type' => $formatType, 'address' => $this));
return $formatType->getRenderer()->render($this);
}
/**
* Retrive address config object
*
* @return Mage_Customer_Model_Address_Config
*/
public function getConfig()
{
return Mage::getSingleton('customer/address_config');
}
This looks like the sort of thing I should introduce to the shipping/billing address variables to get them to come out in the defined HTML format, but I can't quite tie the ends together. Any pointers?