<?php
/**
 * @var array<string, string> $parcelshop_data .
 * @var WC_Order              $order           .
 * @var bool                  $sent_to_admin   .
 * @var bool                  $plain_text      .
 * @var object                $email           .
 *
 * @package DhlPolska\Point
 */

defined( 'ABSPATH' ) || exit;

if ( empty( $parcelshop_data['id'] ) ) {
	return;
}

$street_line = trim( $parcelshop_data['street'] . ' ' . $parcelshop_data['streetNo'] );
$city_line   = trim( $parcelshop_data['zip'] . ' ' . $parcelshop_data['city'] );

if ( $plain_text ) {
	echo esc_html__( 'Wybrany punkt odbioru DHL', 'dhl-polska' ) . "\n";
	if ( '' !== (string) $parcelshop_data['name'] ) {
		echo esc_html( $parcelshop_data['name'] ) . "\n";
	}
	if ( '' !== (string) $parcelshop_data['postnummer'] ) {
		echo esc_html__( 'Postnummer:', 'dhl-polska' ) . ' ' . esc_html( $parcelshop_data['postnummer'] ) . "\n";
	}
	if ( '' !== $street_line ) {
		echo esc_html( $street_line ) . "\n";
	}
	if ( '' !== $city_line ) {
		echo esc_html( $city_line ) . "\n";
	}
	if ( '' !== (string) $parcelshop_data['sap'] ) {
		echo '(' . esc_html( $parcelshop_data['sap'] ) . ")\n";
	}
	echo "\n";
	return;
}
?>
<table id="addresses" cellspacing="0" cellpadding="0" border="0" style="width: 100%; vertical-align: top; margin-bottom: 40px; padding: 0;">
	<tbody>
		<tr>
			<td valign="top" style="text-align: left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding: 0;">
				<h3><?php esc_html_e( 'Wybrany punkt odbioru DHL', 'dhl-polska' ); ?></h3>
				<address class="address">
					<?php if ( ! empty( $parcelshop_data['name'] ) ) : ?>
						<strong><?php echo esc_html( $parcelshop_data['name'] ); ?></strong><br/>
					<?php endif; ?>
					<?php if ( ! empty( $parcelshop_data['postnummer'] ) ) : ?>
						<?php esc_html_e( 'Postnummer:', 'dhl-polska' ); ?>
						<?php echo esc_html( $parcelshop_data['postnummer'] ); ?><br/>
					<?php endif; ?>
					<?php if ( '' !== $street_line ) : ?>
						<?php echo esc_html( $street_line ); ?><br/>
					<?php endif; ?>
					<?php if ( '' !== $city_line ) : ?>
						<?php echo esc_html( $city_line ); ?><br/>
					<?php endif; ?>
					<?php if ( ! empty( $parcelshop_data['sap'] ) ) : ?>
						(<?php echo esc_html( $parcelshop_data['sap'] ); ?>)
					<?php endif; ?>
				</address>
			</td>
		</tr>
	</tbody>
</table>
