<?php
// to check whether accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
global $post;

$product_id   = $post->ID;
$product      = wc_get_product( $product_id );
$product_type = $product->get_type();

echo '<div id="elex_custom_metas">';
		echo '<h4 style="text-align: left;">' . esc_html_e( 'ELEX Catalog Feed for Facebook & Instagram', 'elex-product-feed' ) . '</h4>';

		woocommerce_wp_select(
			array(
				'id'          => '_elex_fpf_sync_enable',
				'label'       => __( 'Facebook Sync', 'elex-product-feed' ),
				'options'     => array(
					'enable'  => 'Enable',
					'disable' => 'Disable',
				),
				'desc_tip'    => 'true',
				'description' => __( 'Enable/Disable Facebook sync', 'elex-product-feed' ),
			)
		);


		
		woocommerce_wp_textarea_input(
			array(
				'id'          => '_elex_fpf_prod_desc',
				'label'       => __( 'Product Description', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'product description', 'elex-product-feed' ),
			)
		);
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_image_link',
				'label'       => __( 'Product Image Link', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'Product Image Link', 'elex-product-feed' ),
			)
		);
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_price',
				'label'       => __( 'Product Price', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'Facebook product Price', 'elex-product-feed' ),
			)
		);
		echo '<div class="brand_gtin_mpn_field_fb_feed hide">';
			echo '<h5 style="text-align: left;">' . esc_html_e( 'Anyone of the Brand, GTIN or MPN is required to create feed', 'elex-product-feed' ) . '</h5>';

			woocommerce_wp_select(
				array(
					'id'          => '_elex_fpf_simple_gtin',
					'label'       => __( 'Select GTIN Type', 'elex-product-feed' ),
					'options'     => array(
						''                   => '',
						'elex_fpf_gtin_upc'  => 'GTIN-USA',
						'elex_fpf_gtin_ean'  => 'GTIN-EAN',
						'elex_fpf_gtin_jan'  => 'GTIN-JAN',
						'elex_fpf_gtin_isbn' => 'GTIN-ISBN',
					),
					'desc_tip'    => 'true',
					'description' => __( 'The Global Trade Item Number (GTIN) is an identifier for trade items', 'elex-product-feed' ),
				)
			);
	
			woocommerce_wp_text_input(
				array(
					'id'          => '_elex_fpf_gtin',
					'label'       => __( 'Enter-GTIN', 'elex-product-feed' ),
					'desc_tip'    => 'true',
					'description' => __( 'The Global Trade Item Number (GTIN) is an identifier for trade items in USA', 'elex-product-feed' ),
				)
			);
			echo wp_kses_post( '<div class="hide" id="_elex_fpf_gtin_error" style="color:red;">' . __( 'Please Enter Valid GTIN Number', 'elex-product-feed' ) . '</div>' );

			woocommerce_wp_text_input(
				array(
					'id'          => '_elex_fpf_mpn',
					'label'       => __( 'MPN', 'elex-product-feed' ),
					'desc_tip'    => 'true',
					'description' => __( 'A manufacturer part number (MPN) is a series of numbers and/or letters given to a part by its manufacturer', 'elex-product-feed' ),
				)
			);
			echo '</div>';
			echo '<div class="message_field_variable_elex_fb hide" >';
			echo '<h5 style="text-align: left;">' . esc_html_e( 'Anyone of the Brand, GTIN or MPN is required to create feed. Please set MPN or GTIN at the variation level.', 'elex-product-feed' ) . '</h5>';
			echo '</div>';

	
			woocommerce_wp_text_input(
				array(
					'id'          => '_elex_fpf_brand',
					'label'       => __( 'Brand', 'elex-product-feed' ),
					'desc_tip'    => 'true',
					'description' => __( 'Required for each product with a clearly associated brand or manufacturer', 'elex-product-feed' ),
				)
			);

	
			?>
		
			<p class="form-field _additional_field_india_field">
				<input type="checkbox" name="_additional_field_india" id="_additional_field_india" 
				<?php 
				$product             = wc_get_product( $post->ID );
				$checked_india_field = $product->get_meta( '_additional_field_india' );
				

				if ( $checked_india_field ) {
					echo 'checked';
				}
				?>

				"> Show Additional required field for selling in  India </input> 
			</p>


			
<?php

		echo '<div id="elex_fb_india_field">';

		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_importer_name',
				'label'       => __( 'Importers Name', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( "If the country of origin is not India, provide the legal entity name of the item's importer.", 'elex-product-feed' ),
			)
		);
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_importer_street1',
				'label'       => __( 'Street 1', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'Required. The first line of the street address.', 'elex-product-feed' ),
			)
		);
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_importer_street2',
				'label'       => __( 'Street 2', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'Optional. Second line of the street address.', 'elex-product-feed' ),
			)
		);
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_importer_city',
				'label'       => __( 'City', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'Required. The city name ', 'elex-product-feed' ),
			)
		);
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_importer_region',
				'label'       => __( 'Region', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( ' Optional. The region, state, county or province.', 'elex-product-feed' ),
			)
		);
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_importer_postal_code',
				'label'       => __( 'Postal Code', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'Optional.The postal code or zip code', 'elex-product-feed' ),
			)
		);

		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_importer_country',
				'label'       => __( 'Import Country', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'Required. Enter the two-letter ISO country code.', 'elex-product-feed' ),
			)
		);

		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_origin_country',
				'label'       => __( 'Origin Country', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( "The item's country of origin. Enter the two-letter ISO country code.", 'elex-product-feed' ),
			)
		);

		echo '<h5 style="text-align: left;">' . esc_html_e( 'Manufacturers Info', 'elex-product-feed' ) . '</h5>';


		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_manufacturer_name',
				'label'       => __( 'Manufacture Name', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'Required. Manufacturer name', 'elex-product-feed' ),
			)
		);
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_manufacturer_address',
				'label'       => __( 'Manufacture Address', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'Required. Manufacturer Address', 'elex-product-feed' ),
			)
		);

		echo '</div>';
		?>
		<p class="form-field _additional_field_usa_field">
				<input type="checkbox" name="_additional_field_usa" id="_additional_field_usa" 
				<?php 
				$product = wc_get_product( $post->ID );

				$checked_usa_field = $product->get_meta( '_additional_field_usa' );
				

				if ( $checked_usa_field ) {
					echo 'checked';
				}
				?>

				"> Show Additional required field for selling in USA </input> 
			</p>
		<?php

		echo '<div id="elex_fb_usa_field">';

		
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_size_usa',
				'label'       => __( 'Size', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( 'The size of the item. Enter the size as a word, abbreviation or number, such as "small", "XL", "12" or "one size". Character limit: 200.', 'elex-product-feed' ),
			)
		);
		woocommerce_wp_text_input(
			array(
				'id'          => '_elex_fpf_sell_usa',
				'label'       => __( 'Quantity To Sell', 'elex-product-feed' ),
				'desc_tip'    => 'true',
				'description' => __( "The quantity of this item that you have available to sell. Enter a whole number.  To prevent overselling, an item's quantity is automatically reduced each time a purchase order is confirmed through checkout. When the quantity reaches 0, the item is marked as sold out in your shop on Facebook and Instagram. After 56 days, out-of-stock items stop appearing in your shop.", 'elex-product-feed' ),
			)
		);

		echo '</div>';

		echo '</div>';

