<?php

use Svea_Webpay_For_Woocommerce\Shortcodes;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

$should_hide_get_address = ( $country === 'SE' || $country === 'DK' ) && Shortcodes::is_using_get_address_shortcode();
?>
<div class="svea-fields svea-part-pay-fields">
	<div class="personal-number-container">
		<?php if ( Shortcodes::is_using_get_address_shortcode() ) : ?>
			<input type="hidden" value="<?php echo isset( $post_data['pp_billing_ssn'] ) ? esc_attr( $post_data['pp_billing_ssn'] ) : ''; ?>"
				name="pp_billing_ssn" />
			<?php
		else :
				woocommerce_form_field(
					'pp_billing_ssn',
					[
						'type'     => ( Shortcodes::is_using_get_address_shortcode() ? 'hidden' : 'text' ),
						'required' => true,
						'class'    => [ 'form-row-wide' ],
						'label'    => __( 'Personal number', 'svea-webpay-for-woocommerce' ),
					],
					isset( $post_data['pp_billing_ssn'] ) ? $post_data['pp_billing_ssn'] : false
				);
		endif;
		?>
	</div>
	<?php if ( ! $should_hide_get_address ) : ?>
		<div class="svea-get-address-button-container">
			<a class="svea-get-address-button" href="#"><?php esc_html_e( 'Get address', 'svea-webpay-for-woocommerce' ); ?></a>
		</div>
	<?php endif; ?>
</div>
