Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't prepend <br> if Recipient and or Organisation are empty #23

Open
jmslbam opened this issue Sep 15, 2024 · 0 comments · May be fixed by #24
Open

Don't prepend <br> if Recipient and or Organisation are empty #23

jmslbam opened this issue Sep 15, 2024 · 0 comments · May be fixed by #24

Comments

@jmslbam
Copy link

jmslbam commented Sep 15, 2024

E.g

$address_formatter['ADMIN_AREA'] = 'Zuid Holland';
$address_formatter['LOCALITY'] = 'Rotterdam'
$address_formatter['POSTAL_CODE'] = '1234AL;
$address_formatter['STREET_ADDRESS'] = 'Highstreet 1337';
$address_formatter['COUNTRY'] = 'Netherlands';

$address_formatter['RECIPIENT'] = '';
$address_formatter['ORGANIZATION'] = '';

//Get the address in localised format
$html = true; // Optional - return the address in HTML <br> instead of \n new lines

$address = $address_formatter->formatAddress($html);

The it returns

<br>Highstreet 1337
<br>1234AL Rotterdam

But the first <br> is not needed, because we don't have a recipient and or organisation.

I have worked around this by adding added $address = trim($address, '<br>'); to my own code because I know I never have something prepended, but it might not be a solid solution know that I think about it.

So the PR, might also not be waterproof if the Locale changes.

Kind regrads,

Jaime!

jmslbam added a commit to jmslbam/address-format that referenced this issue Sep 15, 2024
So if `RECIPIENT` or `ORGANIZATION` are not filled or empty, then this results in only a `STREET_ADDRESS` that's prefix with an `%n` which will be replace by a `<br>` which results in an address that's starts a line lower then needed.

Fixes adamlc#23
@jmslbam jmslbam linked a pull request Sep 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant