File: /var/www/kevin-demo/wp-content/themes/fitmencook/woocommerce/content-single-product.php
<?php
/**
* The template for displaying product content in the single-product.php template
*
* This template can be overridden by copying it to yourtheme/woocommerce/content-single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce\Templates
* @version 3.6.0
*/
use function WPML\FP\Strings\remove;
defined('ABSPATH') || exit;
global $product;
/**
* Hook: woocommerce_before_single_product.
*
* @hooked woocommerce_output_all_notices - 10
*/
do_action('woocommerce_before_single_product');
if (post_password_required()) {
echo get_the_password_form(); // WPCS: XSS ok.
return;
}
?>
<style>
@import url('https://fonts.cdnfonts.com/css/sunfish-original');
</style>
<div class="yoast_breadcrumb fmc_container">
<?php if (function_exists('yoast_breadcrumb')) {
yoast_breadcrumb('<div class="fmc_breadcrumbs spacing_0_2">', '</div>');
} ?>
<?php
$banner_field = get_field('product_banner');
if( $banner_field ) {
// Ako je vraćeno kao array (Image Array)
if( is_array($banner_field) && isset($banner_field['url']) ) {
$url = $banner_field['url'];
$alt = isset($banner_field['alt']) ? $banner_field['alt'] : '';
}
// Ako je vraćeno kao attachment ID
elseif( is_numeric($banner_field) ) {
$url = wp_get_attachment_url( $banner_field );
// Učitaj alt tekst iz attachment meta
$alt = get_post_meta( $banner_field, '_wp_attachment_image_alt', true );
}
// Ako je vraćeno direktno kao URL string
else {
$url = $banner_field;
$alt = '';
}
echo '<div class="product-banner">';
echo '<img src="' . esc_url( $url ) . '" alt="' . esc_attr( $alt ) . '" style="width:100%; max-width:1220px; margin-bottom:4rem; border-radius:11px;">';
echo '</div>';
}
?>
</div>
<div class="custom-product-gallery fmc_container">
<div class="main-image">
<img
id="main-product-image"
src="<?php echo esc_url( wp_get_attachment_url( $product->get_image_id() ) ); ?>"
alt="<?php echo esc_attr( get_the_title() ); ?>"
>
</div>
<div class="thumbnail-gallery-wrapper">
<?php
$attachment_ids = $product->get_gallery_image_ids();
$main_id = $product->get_image_id();
if ( $main_id ) {
array_unshift( $attachment_ids, $main_id );
}
$total_images = count( $attachment_ids );
?>
<?php if ( $total_images > 6 ) : ?>
<button class="thumb-nav thumb-nav-prev" aria-label="Previous">
<svg width="14" height="8" viewBox="0 0 14 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 7L7 1L13 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
<?php endif; ?>
<div class="thumbnail-gallery" data-total="<?php echo esc_attr( $total_images ); ?>">
<?php
if ( $attachment_ids ) {
foreach ( $attachment_ids as $attachment_id ) {
echo '<img
class="thumbnail-image"
src="' . esc_url( wp_get_attachment_url( $attachment_id ) ) . '"
alt="' . esc_attr( get_the_title() ) . '"
>';
}
}
?>
</div>
<?php if ( $total_images > 6 ) : ?>
<button class="thumb-nav thumb-nav-next" aria-label="Next">
<svg width="14" height="8" viewBox="0 0 14 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 1L7 7L13 1" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
<?php endif; ?>
</div>
<div class="product-info-m">
<div class="product-rating">
<?php
$average_rating = $product->get_average_rating();
$review_count = $product->get_review_count();
if ( $review_count > 0 ) {
woocommerce_template_single_rating();
} else {
echo '<div class="fmc_rating_stars">';
echo '<div class="rating-stars">';
for ( $i = 1; $i <= 5; $i++ ) {
echo '<span class="star">☆</span>';
}
echo '</div>';
echo '<span class="reviews-number">(0 reviews)</span>';
echo '</div>';
}
?>
</div>
<h1 class="product-title"><?php echo esc_html( get_the_title() ); ?></h1>
<div class="product-description"><?php woocommerce_template_single_excerpt(); ?></div>
<!-- **************** Start -->
<?php
// Funkcija za trunciranje naziva, ako i dalje želiš skraćivati prvu stavku na npr. 45 znakova.
// (Možeš je izostaviti ako više ne trebaš skraćivanje.)
function fmc_truncate( $text, $max ) {
if ( mb_strlen( $text ) > $max ) {
return mb_substr( $text, 0, $max ) . '…';
}
return $text;
}
$terms = wp_get_post_terms(get_the_ID(), 'product_cat');
if (!empty($terms)) {
$cat_id = intval($terms[0]->term_id);
$coming_soon_products = array(24533, 24534, 22445, 22444, 22443);
// Prikazuje SAMO coming soon proizvode
$loop = new WP_Query([
'post_type' => 'product',
'post__in' => $coming_soon_products,
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => -1
]);
if ($loop->have_posts()) : ?>
<div class="fmc-product-picker">
<!-- Label (možeš promeniti tekst “Spice” po potrebi) -->
<label class="fmc_product_selector" for="fmc-picker-trigger"><?php _e('Spice', 'fmc'); ?></label>
<!-- Dugme koje prikazuje trenutni proizvod -->
<button id="fmc-picker-trigger" class="fmc-picker-trigger" type="button">
<?php
// Trenutni proizvod
$current_id = get_the_ID();
$current_title = get_the_title();
$truncated = function_exists('fmc_truncate') ? fmc_truncate($current_title, 45) : $current_title;
$current_color = get_field('bullet_color', $current_id);
if (!$current_color) {
$current_color = '#344054';
}
?>
<span class="fmc-picker-current">
<span class="fmc-picker-swatch" style="background-color: <?php echo esc_attr($current_color); ?>;"></span>
<?php echo esc_html($truncated); ?>
</span>
<svg class="svg-arrow-down" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 266.77">
<path fill-rule="nonzero" d="M493.12 3.22c4.3-4.27 11.3-4.3 15.62-.04a10.85 10.85 0 0 1 .05 15.46L263.83 263.55c-4.3 4.28-11.3 4.3-15.63.05L3.21 18.64a10.85 10.85 0 0 1 .05-15.46c4.32-4.26 11.32-4.23 15.62.04L255.99 240.3 493.12 3.22z"/>
</svg>
</button>
<!-- Dropdown lista samo coming soon proizvoda -->
<ul id="fmc-picker-dropdown" class="fmc-picker-dropdown">
<?php while ($loop->have_posts()) : $loop->the_post(); ?>
<?php
$other_id = get_the_ID();
$other_title = get_the_title();
$other_color = get_field('bullet_color', $other_id);
if (!$other_color) {
$other_color = '#344054';
}
?>
<li class="fmc-picker-item ">
<a href="<?php the_permalink(); ?>" class="fmc-picker-link">
<span class="fmc-picker-swatch" style="background-color: <?php echo esc_attr($other_color); ?>;"></span>
<span class="fmc-picker-label"><?php echo esc_html($other_title); ?></span>
</a>
</li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
</div>
<?php
endif;
} // ✅ zatvaramo if (!empty($terms))
?>
<!-- **************** -->
<?php
// ACF polja za special offer - GLOBALNA PODEŠAVANJA
$enable_offer = get_field('global_enable_special_offer', 'option');
$discount_qty = get_field('global_discount_quantity', 'option') ?: 3;
$discount_pct = get_field('global_discount_percent', 'option') ?: 10;
$offer_title_acf = get_field('global_offer_title', 'option') ?: 'SPECIAL OFFER';
$base_price = $product->get_price();
$currency = get_woocommerce_currency_symbol();
?>
<?php if ( $enable_offer ) : ?>
<div class="special-offer">
<svg class="special-offer-svg" width="31" height="40" viewBox="0 0 31 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0.642609 0C0.471515 0.000692035 0.307702 0.0693129 0.187194 0.19077C0.0666846 0.312227 -0.000639162 0.476577 4.57431e-06 0.647676V39.3594C0.000843651 39.4749 0.0326558 39.5881 0.0921294 39.687C0.151603 39.786 0.236542 39.8673 0.338106 39.9222C0.439669 39.9772 0.554146 40.0039 0.669547 39.9995C0.784947 39.9952 0.897044 39.9599 0.994179 39.8975L15.4811 30.452L29.9707 39.8975C30.0678 39.9599 30.1799 39.9952 30.2953 39.9995C30.4107 40.0039 30.5252 39.9772 30.6267 39.9222C30.7283 39.8672 30.8132 39.786 30.8727 39.687C30.9322 39.5881 30.964 39.4749 30.9648 39.3594V0.647676C30.9652 0.56285 30.9487 0.478791 30.9165 0.400314C30.8843 0.321836 30.837 0.250478 30.7772 0.190321C30.7174 0.130165 30.6463 0.0823918 30.568 0.0497343C30.4897 0.0170768 30.4058 0.000176398 30.321 0H15.7533H0.642609Z" fill="#FF4D49"/>
<path d="M11.0132 7.74444C9.37791 7.78625 8.05078 9.1375 8.05078 10.7825C8.05078 12.4535 9.41907 13.8255 11.0901 13.8255C12.7611 13.8255 14.1281 12.4535 14.1281 10.7825C14.1281 9.11139 12.7611 7.74444 11.0901 7.74444C11.064 7.74444 11.0391 7.74377 11.0132 7.74444ZM21.4415 8.54583C21.3452 8.53577 21.2478 8.54754 21.1566 8.58027C21.0654 8.61299 20.9828 8.66583 20.9148 8.73486L9.03744 20.6853C8.97768 20.7456 8.93039 20.817 8.89828 20.8956C8.86618 20.9741 8.84991 21.0583 8.85036 21.1431C8.85082 21.228 8.86799 21.3119 8.90093 21.3901C8.93387 21.4683 8.98192 21.5393 9.04231 21.5989C9.16382 21.718 9.32746 21.7843 9.49762 21.7833C9.66777 21.7824 9.83068 21.7142 9.95084 21.5938L21.8295 9.64455C21.8897 9.58459 21.9376 9.51332 21.9702 9.43482C22.0028 9.35633 22.0196 9.27216 22.0196 9.18715C22.0196 9.10214 22.0028 9.01796 21.9702 8.93947C21.9376 8.86097 21.8897 8.78969 21.8295 8.72974C21.7256 8.6264 21.5872 8.56159 21.4415 8.54583ZM11.0447 9.03474C11.0594 9.03437 11.0755 9.03474 11.0901 9.03474C12.0638 9.03474 12.839 9.80876 12.839 10.7825C12.839 11.7562 12.0638 12.5352 11.0901 12.5352C10.1164 12.5352 9.34235 11.7562 9.34235 10.7825C9.34235 9.82397 10.0925 9.05839 11.0447 9.03474ZM19.8715 16.5019C18.2005 16.5019 16.8284 17.8739 16.8284 19.545C16.8284 21.216 18.2005 22.5855 19.8715 22.5855C21.5425 22.5855 22.9095 21.216 22.9095 19.545C22.9095 17.8739 21.5425 16.5019 19.8715 16.5019ZM19.8261 17.7922C19.8408 17.7918 19.8569 17.7922 19.8715 17.7922C20.8451 17.7922 21.6205 18.5713 21.6205 19.545C21.6205 20.5187 20.8451 21.2939 19.8715 21.2939C18.8978 21.2939 18.12 20.5187 18.12 19.545C18.12 18.5865 18.8739 17.8161 19.8261 17.7922Z" fill="#FECF0C"/>
</svg>
<p class="offer-title"><?php echo esc_html( $offer_title_acf ); ?></p>
<p class="offer-details">Buy <?php echo esc_html( $discount_qty ); ?> and get <?php echo esc_html( $discount_pct ); ?>% off!</p>
</div>
<div class="no-discount-price-wrapper">
<p id="total-price"><?php echo wc_price( $base_price * $discount_qty ); ?></p>
<div class="stock-status-wrapper">
<?php if ( $product->is_in_stock() ) : ?>
<p class="stock in-stock">
✅ In stock
</p>
<?php else : ?>
<p class="stock out-of-stock">❌ Out of stock</p>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="product-price-wrapper"
data-enable-offer="<?php echo $enable_offer ? '1' : '0'; ?>"
data-discount-qty="<?php echo esc_attr( $discount_qty ); ?>"
data-discount-pct="<?php echo esc_attr( $discount_pct ); ?>"
>
<div class="discounted-price-wrapper">
<p
class="discounted-price"
data-base-price="<?php echo esc_attr( $base_price ); ?>"
data-currency="<?php echo esc_attr( $currency ); ?>"
>
<?php echo wc_price( $base_price ); ?>
</p>
</div>
<div class="quantity-wrapper">
<button type="button" class="quantity-minus">-</button>
<input class="input-number" type="number" id="quantity" value="1" min="1" step="1">
<button type="button" class="quantity-plus">+</button>
</div>
</div>
<form class="cart-m" method="post" enctype="multipart/form-data">
<input type="hidden" id="calculated-price" name="calculated-price" value="<?php echo $product->get_price() * 1; ?>">
<input type="hidden" id="quantity-value" name="quantity" value="1">
<button class="add-to-cart-btn-m" type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt">
<svg width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 2.5H4.66667L5 4.16667M6.33333 10.8333H14.6667L18 4.16667H5M6.33333 10.8333L5 4.16667M6.33333 10.8333L4.42259 12.7441C3.89762 13.269 4.26942 14.1667 5.01184 14.1667H14.6667M14.6667 14.1667C13.7462 14.1667 13 14.9129 13 15.8333C13 16.7538 13.7462 17.5 14.6667 17.5C15.5871 17.5 16.3333 16.7538 16.3333 15.8333C16.3333 14.9129 15.5871 14.1667 14.6667 14.1667ZM8 15.8333C8 16.7538 7.25381 17.5 6.33333 17.5C5.41286 17.5 4.66667 16.7538 4.66667 15.8333C4.66667 14.9129 5.41286 14.1667 6.33333 14.1667C7.25381 14.1667 8 14.9129 8 15.8333Z" stroke="#151921" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
Add to cart
</button>
</form>
</div>
</div>
<?php if (have_rows('global_product_content_icons', 'option')): ?>
<div class="flex-list flex-list-m">
<?php while (have_rows('global_product_content_icons', 'option')): the_row();
$icon = get_sub_field('global_product_content_icon_image');
$text = get_sub_field('global_product_content_icon_text');
?>
<div class="fmc_content_container">
<?php if ($icon): ?>
<img src="<?php echo esc_url($icon); ?>" alt="<?php echo esc_attr($text); ?>">
<?php endif; ?>
<?php if ($text): ?>
<p><?php echo esc_html($text); ?></p>
<?php endif; ?>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<!-- PRVA SEKCIJA -->
<div class="main-container-wrapper product-section-m">
<div class="fmc_container product_info_section">
<!-- Leva strana -->
<div class="product-image-wrapper-m">
<?php
// Proveri da li proizvod ima POPUNJENE slike (ne samo prazan repeater)
$has_product_images = false;
$product_images = get_field('product_content_left_image');
if ($product_images && is_array($product_images)) {
foreach ($product_images as $row) {
if (!empty($row['big_image']) || !empty($row['small_decoration_image'])) {
$has_product_images = true;
break;
}
}
}
if ($has_product_images): ?>
<?php while (have_rows('product_content_left_image')): the_row();
$big_image = get_sub_field('big_image');
$small_decoration_image = get_sub_field('small_decoration_image');
?>
<?php if($big_image): ?>
<img class="big-image-m" src="<?php echo esc_url($big_image); ?>" alt="Product Big Image">
<?php endif; ?>
<?php if($small_decoration_image): ?>
<img class="decoration-normal-image" src="<?php echo esc_url($small_decoration_image); ?>" alt="Decoration image">
<?php endif; ?>
<?php endwhile; ?>
<?php elseif(have_rows('global_product_content_left_image','option')): ?>
<?php // Fallback na globalne slike ?>
<?php while (have_rows('global_product_content_left_image', 'option')): the_row();
$big_image = get_sub_field('big_image');
$small_decoration_image = get_sub_field('small_decoration_image');
?>
<?php if($big_image): ?>
<img class="big-image-m" src="<?php echo esc_url($big_image); ?>" alt="Product Big Image">
<?php endif; ?>
<?php if($small_decoration_image): ?>
<img class="decoration-normal-image" src="<?php echo esc_url($small_decoration_image); ?>" alt="Decoration image">
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<!-- Desna strana -->
<div class="product-info-wrapper ">
<div class="ingredients-section item ">
<div class="product-title-wrapper">
<?php
$ingredients_title = get_field('ingredients_heading','option');
?>
<h3 class="product-info-heading"><?php echo esc_html($ingredients_title)?></h3>
<ion-icon class="product-icon-plus product-icon" name="add-outline"></ion-icon>
</div>
<ul class="hidden-box ul-product">
<?php
$selected_ingredients = get_field('product_ingredients_checkbox');
if ($selected_ingredients):
foreach ($selected_ingredients as $ingredient_name): ?>
<li><?php echo esc_html($ingredient_name); ?></li>
<?php endforeach; ?>
<?php else: ?>
<li>No ingredients selected.</li>
<?php endif; ?>
</ul>
</div>
<div class="product-info-section item open">
<div class="product-title-wrapper">
<?php
$product_info_title = get_field('product_info_heading','option');
?>
<h3 class="product-info-heading"><?php echo esc_html($product_info_title)?></h3>
<ion-icon class="product-icon-plus product-icon" name="remove-outline"></ion-icon>
</div>
<div class="hidden-box">
<?php echo wp_kses_post($product->get_description()); ?>
</div>
</div>
<?php
$how_to_use = get_field('how_to_use');
$how_to_use_heading = get_field('product_how_to_use', 'option') ?: 'How To Use';
if ( $how_to_use ) : ?>
<div style='margin-top: 2rem' class="how-to-use-section item">
<div class="product-title-wrapper">
<h3 class="product-info-heading"><?php echo esc_html( $how_to_use_heading ); ?></h3>
<ion-icon class="product-icon-plus product-icon" name="add-outline"></ion-icon>
</div>
<div class="hidden-box">
<?php echo wp_kses_post( $how_to_use ); ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php
// Dodatna sekcija sa naslovom i tekstom
$additional_title = get_field('product_additional_title');
$additional_content = get_field('product_additional_content');
if ($additional_title || $additional_content): ?>
<div class="product-additional-section fmc_container">
<?php if ($additional_title): ?>
<h2 style="padding-bottom: 20px;" class="product-additional-title"><?php echo esc_html($additional_title); ?></h2>
<?php endif; ?>
<?php if ($additional_content): ?>
<div class="product-additional-content">
<?php echo wp_kses_post($additional_content); ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
// 1) Query svih connection custom postova koji su povezani sa ovim proizvodom
$connections = get_posts([
'post_type' => 'connection',
'posts_per_page' => -1,
'meta_query' => [[
'key' => 'connected_product',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE',
]],
]);
// 2) Skupi sve recepte iz repeatera 'recipes' u jedan array i upamti poslednji connection URL
$connection_recipes_all = [];
$connection_url = '';
if ( $connections ) {
foreach ( $connections as $conn ) {
$connection_url = get_permalink( $conn->ID );
if ( $recs = get_field( 'recipes', $conn->ID ) ) {
foreach ( $recs as $r ) {
$connection_recipes_all[ $r->ID ] = $r;
}
}
}
}
// 3) Ako ima više od 3 recepata, izvuci 4 nasumična
if ( count( $connection_recipes_all ) > 3 ) {
$keys = array_rand( $connection_recipes_all, 4 );
$tmp = [];
foreach ( (array) $keys as $k ) {
$tmp[ $k ] = $connection_recipes_all[ $k ];
}
$connection_recipes_all = $tmp;
}
// 4) Ispiši sekciju samo ako ima bar jednog recepta
if ( $connection_recipes_all ) : ?>
<div class="how-to-use-section fmc_container item open">
<div class="product-title-wrapper no-cursor">
<?php
$recipes_title= get_field('related_recipes_heading','option');
?>
<h3 class="product-info-heading"><?php echo esc_html($recipes_title)?></h3>
<!-- <ion-icon class="product-icon-minus product-icon" name="remove-outline"></ion-icon> -->
</div>
<div class="recipes-m "> <!--hidden-box class removed -->
<?php
global $post;
foreach ( $connection_recipes_all as $connected_recipe ) :
$post = $connected_recipe;
setup_postdata( $post );
// tvoj template part za pojedinačni recept:
get_template_part( 'template-parts/recipe/recipe', 'rel' );
endforeach;
wp_reset_postdata();
?>
</div>
<a href="<?php echo esc_url( $connection_url ); ?>" class="view-link bg-link-m">
View All Recipes <span>→</span>
<?php endif; ?></a>
</div>
</div>
<?php if (have_rows('global_product_content_scrolling_banner', 'option')): ?>
<div class="scrolling-banner scrolling-banner-m">
<div class="scrolling-content">
<?php
// Generiši osnovni set stavki
while (have_rows('global_product_content_scrolling_banner', 'option')): the_row();
$text = get_sub_field('global_product_content_banner_text');
$image = get_sub_field('global_product_content_banner_image');
?>
<div class="scrolling-item">
<?php if ($text): ?>
<span><?php echo esc_html($text); ?></span>
<?php endif; ?>
<?php if ($image): ?>
<img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr($text); ?>">
<?php endif; ?>
</div>
<?php endwhile; ?>
<?php
// Dupliraj sadržaj za kontinuiranu animaciju
if (have_rows('global_product_content_scrolling_banner', 'option')):
while (have_rows('global_product_content_scrolling_banner', 'option')): the_row();
$text = get_sub_field('global_product_content_banner_text');
$image = get_sub_field('global_product_content_banner_image');
?>
<div class="scrolling-item">
<?php if ($text): ?>
<span><?php echo esc_html($text); ?></span>
<?php endif; ?>
<?php if ($image): ?>
<img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr($text); ?>">
<?php endif; ?>
</div>
<?php endwhile; endif; ?>
</div>
</div>
<?php endif; ?>
<?php
// Dohvati izabrane sastojke za trenutni proizvod
$selected_ingredients = get_field('product_ingredients_checkbox');
if ($selected_ingredients) :
// Dohvati globalne sastojke i benefite
if (have_rows('global_ingredients_and_benefits', 'option')) : ?>
<div class="big-wrapper-m">
<div class="fmc_container">
<div class="ingredient-bennefits-title-wrapper">
<p class="special-text"><?php echo esc_html(get_field('global_content_product_small_text', 'option')); ?></p>
<h3 class="ingredient-benefit-title"><?php echo esc_html(get_field('global_product_content_ingredient_title_text', 'option')); ?></h3>
</div>
<div class="ingredients-benefits">
<?php
$icon1 = get_field('global_product_content_icon_1', 'option'); // ID slike
$text1 = get_field('global_product_content_text_1', 'option'); // tekst
$icon2 = get_field('global_product_content_icon_2', 'option');
$text2 = get_field('global_product_content_text_2', 'option');
?>
<div class="ingredient-benefit-item-special">
<p>
<?php if ( $icon1 ) : ?>
<img class="ingredient-special-img" src="<?php echo esc_url( $icon1 ); ?>" alt="">
<?php endif; ?>
<?php if ( $text1 ) : ?>
<?php echo esc_html( $text1 ); ?>
<?php endif; ?>
</p>
<p>
<?php if ( $icon2 ) : ?>
<img class="ingredient-special-img" src="<?php echo esc_url( $icon2 ); ?>" alt="">
<?php endif; ?>
<?php if ( $text2 ) : ?>
<?php echo esc_html( $text2 ); ?>
<?php endif; ?>
</p>
</div>
<?php
// Iteriraj kroz globalne sastojke
while (have_rows('global_ingredients_and_benefits', 'option')) :
the_row();
$ingredient_name = get_sub_field('ingredient_name');
$ingredient_benefit = get_sub_field('ingredient_benefit');
// Proveri da li je trenutni sastojak izabran za ovaj proizvod
if (in_array($ingredient_name, $selected_ingredients)) : ?>
<div class="ingredient-benefit-item">
<div class="ingredient">
<strong><?php echo esc_html($ingredient_name); ?></strong>
</div>
<div class="benefit">
<?php echo esc_html($ingredient_benefit); ?>
</div>
</div>
<?php endif; ?>
<?php endwhile; ?>
</div>
</div>
<?php endif;
else : ?>
<p>No ingredients or benefits selected for this product.</p>
<?php endif; ?>
</div>
<div class="fmc_container">
<?php
if (comments_open() || get_comments_number()) {
comments_template();
}
?>
</div>
<?php
$related_ids = wc_get_related_products( get_the_ID(), 4 );
$related_products = array_map( 'wc_get_product', $related_ids );
if ( $related_products ) : ?>
<section class="related products spacing_1 fmc_container">
<?php
$heading = apply_filters(
'woocommerce_product_related_products_heading',
__( 'Related products', 'woocommerce' )
);
if ( $heading ) {
echo '<h2 class="fmc_title_2 title_spacing_2">' . esc_html( $heading ) . '</h2>';
}
woocommerce_product_loop_start();
foreach ( $related_products as $related_product ) :
$post_object = get_post( $related_product->get_id() );
setup_postdata( $GLOBALS['post'] =& $post_object );
get_template_part( 'template-parts/content', 'product' );
endforeach;
woocommerce_product_loop_end();
?>
<img class="absolute-image-2" src="/wp-content/uploads/2025/01/AdobeStock_385724393-1.png" alt="Featured Section Background">
<?php
wp_reset_postdata();
?>
</section>
<?php endif; ?>
<div class="fmc_container see-all-products-div">
<a href="/product-category/spices/" class="view-link bg-link-m">
Explore All Products <span>→</span>
</a>
</div>