<?php
/**
 * Status tab – WooCommerce Settings.
 *
 * @package flo-sync
 */

use NMFS\Shared;
use NMFS\Sync\Items\Articles\Stock\Shipping;

defined( 'ABSPATH' ) || exit;

/**
 * View file parameters.
 *
 * @var array $params
 */

?>
	<h2 id="shipping-methods"><?php esc_html_e( 'Shipping methods', 'flo-sync' ); ?></h2>
	<table class="nmf-sync-table">
		<thead>
		<tr>
			<th>ID</th>
			<th>Method title</th>
			<th>Enabled</th>
			<th>Type</th>
		</tr>
		</thead>
		<?php
		foreach ( $params['shipping_zones'] as $shipping_zone ) {
			?>
			<thead>
			<tr>
				<th colspan="4">
					<?php echo esc_html( $shipping_zone['zone_name'] ); ?>
				</th>
			</tr>
			</thead>
			<tbody>
			<?php
			if ( ! empty( $shipping_zone['shipping_methods'] ) ) {
				foreach ( $shipping_zone['shipping_methods'] as $shipping_method ) {
					echo '<tr>';
					echo '<td>' . esc_html( $shipping_method->id ) . '</td>';
					echo '<td>' . esc_html( $shipping_method->method_title ) . '</td>';
					echo '<td>' . esc_html( $shipping_method->enabled ) . '</td>';
					echo '<td>' . esc_html( Shipping::get_shipping_method_type_by_shipping_method( $shipping_method ) ) . '</td>';
					echo '</tr>';
				}
			} else {
				echo '<tr><td colspan="4">';
				esc_html_e( 'This shipping zone contains no shipping methods', 'flo-sync' );
				echo '</td></tr>';
			}
			?>
			</tbody>
			<?php
		}
		?>
	</table>

	<h2 id="price-decimals"><?php esc_html_e( 'Price decimals', 'flo-sync' ); ?></h2>
	<p><?php echo esc_html( wc_get_price_decimals() ); ?></p>
	<h3>
		<?php
		printf(
		// translators: %s: hook name.
			esc_html__( 'Hooks for %s', 'flo-sync' ),
			'woocommerce_price_num_decimals'
		);
		?>
	</h3>
<?php Shared::instance()->debug->display_hooks( 'wc_get_price_decimals' ); ?>
	<h3>
		<?php
		printf(
		// translators: %s: WordPress option name.
			esc_html__( 'Hooks for the option retrieval of %s', 'flo-sync' ),
			'woocommerce_price_num_decimals'
		);
		?>
	</h3>
<?php Shared::instance()->debug->display_hooks( 'option_woocommerce_price_num_decimals' ); ?>
<?php Shared::instance()->debug->display_hooks( 'pre_option_woocommerce_price_num_decimals' ); ?>
