<?php
include ('get_products.php');
?> <div class="container">
  <div class="product-listing"> <?php while ($products->have_posts()) {
	$products->the_post();
	global $product;
	$product_id = get_the_ID();

	$image = wp_get_attachment_image_src( get_post_thumbnail_id( $product_id ), 'single-post-thumbnail' );
	$weightloss = get_field('weightloss');

	$post_date = get_the_date( 'YmdHis' );
	$regular_price = $product->get_regular_price();
	$formatted_price = wc_price($regular_price);

	$tagsterms = wp_get_post_terms(get_the_id(),'product_tag');

    $producttags = ''; $prodtags = array();
    if(count($tagsterms) > 0) {
        foreach($tagsterms as $tagterm){
            $term_name = $tagterm->name;
            $prodtags[] = "prodtg_".strtolower($term_name);
        }
		if(!empty($prodtags))
		{
			$producttags = implode(' ',$prodtags);
		}
    }
	?>
	<div class="product-block <?php echo $producttags; ?> <?php echo (in_array($product_id, $cart_product))?" is-selected ":"" ?> prdpack_<?php echo $product_id; ?>" data-pack-id="<?php echo $product_id; ?>" data-orderno="<?php echo $post_date ?>" id="product_<?php echo $product_id; ?>" data-prdid="<?php echo $product_id; ?>" style="order: <?php if($product_id === 1314 || $product_id === 1372 || $product_id === 1432) echo 1 ?> <?php if($product_id === 1313 || $product_id === 1370 || $product_id === 2514) echo 2 ?> <?php if($product_id === 1315 || $product_id === 1373 || $product_id === 1433) echo 3 ?>">
      <div class="product-block-inner">
        <div class="pd-top"> <?php if(!empty(get_field('last_sale_text'))){ ?> <p class="product-label">
            <strong> <?php echo __("Last sale","fitsmartio"); ?> </strong>
            <br> <?php echo get_field('last_sale_text') ?>
          </p>
          <!--=============== NEW METAFIELD ==================--> <?php } ?> <?php if(!empty(get_field('tooltip_text'))){ ?> <div class="product-heading">
            <h3> <?php echo get_field('tooltip_text'); ?> </h3>
          </div> <?php } ?> <div class="product-img">
            <img src="
								<?php echo $image[0]; ?>" alt="product-img">
          </div>
        </div>
        <div class="pd_body">
          <div class="product-name">
            <h3> <?php echo get_the_title(); ?> </h3>
          </div> <?php if(!empty(get_field('featured_text1'))){ ?> <div class="product-sub">
            <!--================= NEW METAFIELD =================-->
            <p>
              <svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 512 512">
                <!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
                <path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209c9.4-9.4 9.4-24.6 0-33.9s-24.6-9.4-33.9 0l-111 111-47-47c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l64 64c9.4 9.4 24.6 9.4 33.9 0L369 209z" />
              </svg> <?php echo get_field('featured_text1'); ?>
            </p>
          </div> <?php } ?> <div class="product-features">
            <!--=============== NEW METAFIELD =================-->
            <ul> <?php if(!empty(get_field('featured_text2'))){ ?> <li>
                <span>
                  <svg aria-hidden="true" class="e-font-icon-svg e-fas-check-circle" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
                    <path d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"></path>
                  </svg>
                </span>
                <span> <?php echo get_field('featured_text2'); ?> </span>
              </li> <?php } ?> <?php if(!empty(get_field('featured_text3'))){ ?> <li>
                <span>
                  <svg aria-hidden="true" class="e-font-icon-svg e-fas-check-circle" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
                    <path d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"></path>
                  </svg>
                </span>
                <span> <?php echo get_field('featured_text3'); ?> </span>
                <!--=============== NEW METAFIELD REPEATER =================-->
              </li> <?php } ?> </ul>
          </div>
          <div class="product-price">
            <div class="product-price-wrapper">
              <div class="product-price-bottle"> <?php echo __('previously', 'fitsmartio_en'); ?>: <?php if(!empty($vorher_price=get_field('vorher_price'))){ ?> <p class="old-price mb-0">
                  <span class="big"> <?php echo  $vorher_price; ?> <?php echo get_woocommerce_currency_symbol(); ?> </span>
                </p> <?php } ?> <?php if(!empty(get_field('pro_packung_price'))){ ?> <p>
                  <span class="big"> <?php echo get_field('pro_packung_price'); ?> <?php echo get_woocommerce_currency_symbol(); ?> </span>
                  <br> <?php
							echo __('Price per pack', 'fitsmartio_en');
							//Preis pro Packung//Gesamtpreis//AUSWÄHLEN
							?>
                </p> <?php } ?> </div> <?php
					//echo get_field('neu_price_without_fee')
					$product_price_val = $product->get_price();

					$regular_price = $product->get_regular_price();
					$sale_price = $product->get_sale_price();
					?> <div class="product-price-total"> <?php echo __('Total price', 'fitsmartio_en');  ?> <?php echo $product_price_val; ?>&nbsp; <?php echo get_woocommerce_currency_symbol(); ?> </div>
            </div> <?php /*

									<div class="payment__inf">
										<?php if(!empty(get_field('klarna_text'))){ ?> <div class="kalrna-div">
              <!--=============== NEW METAFIELD =================-->
              <img src="https://fitsmart.io/staging/wp-content/uploads/2023/11/image-30.png" alt="" />
              <span> <?php echo get_field('klarna_text'); ?> </span>
            </div> <?php } ?> <?php if(!empty(get_field('paypal_text'))){ ?> <div class="paypal-div">
              <!--=============== NEW METAFIELD =================-->
              <img src="https://fitsmart.io/wp-content/uploads/2023/12/image-31.png" alt="" />
              <span> <?php echo get_field('paypal_text'); ?> </span>
            </div> <?php } ?>
          </div> */ ?> <div class="payment__inf">
            <div class="eltext"> <?php echo __('Pay later with', 'fitsmartio_en'); ?> </div>
            <div class="kalrna-paypal-el">
              <img width="58" height="29" src="
												<?php echo get_site_url(); ?>/wp-content/uploads/2024/03/image-30.webp" alt="icon" />
              <img width="92" height="29" src="
													<?php echo get_site_url(); ?>/wp-content/uploads/2024/03/image-31.webp" alt="icon">
            </div>
          </div>
        </div>
        <div class="product-link">
		    <?php
			$button_label = (in_array($product_id, $cart_product)) ? __('CHOSEN', 'fitsmartio_en') : __('CHOOSE', 'fitsmartio_en');
			?>
            <a href="javascript:void(0);" alt="product-link"> <?php echo $button_label;  ?> </a>
        </div>
      </div>
    </div>
    <div class="excellent_reviews">
      <!--=============== NEW METAFIELD  =================--> <?php if(!empty(get_field('rating_number'))){ ?> <ul> <?php
			$rating_number=get_field('rating_number');
			for($i=1; $i<=5 ; $i++){
				if($rating_number>=$i){
				?> <li>
          <svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512">
            <!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.-->
            <path d="M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z" fill="#A688A6" />
          </svg>
        </li> <?php }else{ ?> <li>
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
            <path d="M287.9 0c9.2 0 17.6 5.2 21.6 13.5l68.6 141.3 153.2 22.6c9 1.3 16.5 7.6 19.3 16.3s.5 18.1-5.9 24.5L433.6 328.4l26.2 155.6c1.5 9-2.2 18.1-9.7 23.5s-17.3 6-25.3 1.7l-137-73.2L151 509.1c-8.1 4.3-17.9 3.7-25.3-1.7s-11.2-14.5-9.7-23.5l26.2-155.6L31.1 218.2c-6.5-6.4-8.7-15.9-5.9-24.5s10.3-14.9 19.3-16.3l153.2-22.6L266.3 13.5C270.4 5.2 278.7 0 287.9 0zm0 79L235.4 187.2c-3.5 7.1-10.2 12.1-18.1 13.3L99 217.9 184.9 303c5.5 5.5 8.1 13.3 6.8 21L171.4 443.7l105.2-56.2c7.1-3.8 15.6-3.8 22.6 0l105.2 56.2L384.2 324.1c-1.3-7.7 1.2-15.5 6.8-21l85.9-85.1L358.6 200.5c-7.8-1.2-14.6-6.1-18.1-13.3L287.9 79z"  fill="#A688A6"></path>
          </svg>
        </li> <?php } } ?> </ul> <?php } ?> <?php
            //Kundenbewertungen//Zu den Bewertungen
            ?> </ul> <?php if(!empty(get_field('rating_text'))){ ?>
      <!--=============== NEW METAFIELD  =================-->
      <p> <?php echo __('Customer reviews', 'fitsmartio_en');  ?> <strong> <?php echo get_field('rating_text') ?> </strong>
      </p> <?php } ?> <a href="javascript:void(0)" class="to_reviews_txt">
        <svg xmlns="http://www.w3.org/2000/svg" height="16" width="14" viewBox="0 0 448 512">
          <!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.-->
          <path d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3 .4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z" fill="#A688A6" />
        </svg> <?php echo __('To the reviews', 'fitsmartio_en');  ?> </a>
    </div>
  </div> <?php }  ?>
</div>
</div>
