<?php
/**
 * Displays top header
 *
 * @package Gym Nutrition Shop
 */
?>
<?php
$gym_nutrition_shop_sticky_header = get_theme_mod('gym_nutrition_shop_sticky_header');
    $gym_nutrition_shop_data_sticky = "false";
    if ($gym_nutrition_shop_sticky_header) {
    $gym_nutrition_shop_data_sticky = "true";
  }
 ?>
<div class="top-info py-2" data-sticky="<?php echo esc_attr($gym_nutrition_shop_data_sticky); ?>">
	<div class="container">
		<div class="row">
			<div class="col-lg-3 col-md-12 align-self-center">
                <div class="top-left">
                    <?php if(get_theme_mod('gym_nutrition_shop_top_header_picking_url') != '') {?>
                        <a href="<?php echo esc_url(get_theme_mod('gym_nutrition_shop_top_header_picking_url')); ?>" target="_blank"><?php echo esc_html('Picking Up?', 'gym-nutrition-shop'); ?></a>
                    <?php }?>
                    <div id="product-store-filter">
                        <select id="store-filter" onchange="if(this.value) window.location.href=this.value;">
                            <option value="<?php echo esc_url( remove_query_arg('Productstore') ); ?>">Select Store</option>
                            <?php
                                $stores = get_terms(array(
                                    'taxonomy'   => 'product_store',
                                    'hide_empty' => true,
                                ));

                            if (!empty($stores) && !is_wp_error($stores)) {
                                foreach ($stores as $store) {
                                    $selected = (isset($_GET['Productstore']) && $_GET['Productstore'] === $store->slug) ? 'selected' : '';
                                    echo '<option value="' . esc_url(add_query_arg('Productstore', $store->slug)) . '" ' . $selected . '>' . esc_html($store->name) . '</option>';
                                }
                            } ?>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-lg-6 col-md-12 align-self-center">
                <?php if(get_theme_mod('gym_nutrition_shop_top_header_sale_head_text') != '' || get_theme_mod('gym_nutrition_shop_top_header_sale_text') != '') {?>
                    <p class="sale-text m-0 text-center"><span class="sale-head"><?php echo esc_html(get_theme_mod('gym_nutrition_shop_top_header_sale_head_text')); ?></span> <span class="sale-content"><?php echo esc_html(get_theme_mod('gym_nutrition_shop_top_header_sale_text')); ?></span></p>
                <?php }?>
            </div>
            <div class="col-lg-3 col-md-12 align-self-center">
                <div class="top-right">
                    <?php if(get_theme_mod('gym_nutrition_shop_top_header_delivery_url') != '') {?>
                        <a href="<?php echo esc_url(get_theme_mod('gym_nutrition_shop_top_header_delivery_url')); ?>" target="_blank"><?php echo esc_html('Need Delivery?', 'gym-nutrition-shop'); ?></a>
                    <?php }?>
                    <?php if(get_theme_mod('gym_nutrition_shop_top_header_estimates_url') != '') {?>
                        <a href="<?php echo esc_url(get_theme_mod('gym_nutrition_shop_top_header_estimates_url')); ?>" target="_blank"><?php echo esc_html('See Estimates', 'gym-nutrition-shop'); ?></a>
                    <?php }?>
                </div>
            </div>
		</div>
	</div>
</div>