<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use Prodigy\Includes\Helpers\Prodigy_Formatting;
use Prodigy\Includes\Helpers\Prodigy_Platform_Settings;
use Prodigy\Includes\Prodigy;

if ( ! empty( $main_sku ) && $enable_product_sku ) : ?>
	<li class="prodigy-product__tags-item product_sku">
		<span class="prodigy-product__tags-label">
			<?php esc_html_e( 'Sku:', 'prodigy-commerce' ); ?>
		</span>
	<span class="prodigy-product__tags-text product_sku_value">
			<?php echo esc_html( $main_sku ); ?>
		</span>
	</li>
<?php endif; ?>

<?php if ( Prodigy_Platform_Settings::is_redemption_store_status() ) : ?>
	<?php if ( isset( $charge_amount ) && $charge_amount > 0 ) : ?>
	<li class="prodigy-product__tags-item">
		<span
		class="prodigy-product__tags-label"><?php esc_html_e( 'Setup Charge:', 'prodigy-commerce' ); ?></span>
		<span
		class="prodigy-product__tags-text"><?php echo esc_html( get_option( 'pg_currency_type' ) . Prodigy_Formatting::prodigy_price_format( $charge_amount ) ); ?></span>
	</li>
	<?php endif; ?>
<?php endif; ?>

<?php if ( ! empty( $categories ) && $enable_product_categories ) : ?>
	<li class="prodigy-product__tags-item">
		<span class="prodigy-product__tags-label">
			<?php echo wp_kses( _n( 'Category:', 'Categories:', $count_categories, 'prodigy-commerce' ), Prodigy_Formatting::get_allowed_html() ); ?>
		</span>
	<span class="prodigy-product__tags-text">
			<?php
			foreach ( $categories as $key => $category ) {
				$category_info = get_term_by( 'id', $category->term_id, Prodigy::get_prodigy_category_type() );
				$category_link = get_category_link( $category_info->term_id );
				if ( isset( $_GET['brand'] ) ) {
					$category_link = add_query_arg(
						array(
							'brand' => $_GET['brand'],
						),
						$category_link
					);
				}
				echo '<a href="' . esc_attr( $category_link ) . '">' . esc_attr( $category_info->name ) . '</a>';
				if ( ++$key != $count_categories ) {
					echo ', ';
				}
			}
			?>
		</span>
	</li>
<?php endif; ?>
