ruạṛ
<?php /** * Single Product Template */ get_header(); $part_number = get_post_meta(get_the_ID(), '_ie_part_number', true); $short_desc = get_post_meta(get_the_ID(), '_ie_short_description', true); $categories = get_the_terms(get_the_ID(), 'product_category'); ?> <div class="breadcrumbs"> <div class="breadcrumbs-inner"> <a href="<?php echo home_url('/'); ?>">Home</a> <span class="separator">›</span> <a href="<?php echo get_post_type_archive_link('product'); ?>">Catalogue</a> <span class="separator">›</span> <?php if ($categories && !is_wp_error($categories)): ?> <a href="<?php echo get_term_link($categories[0]); ?>"> <?php echo esc_html($categories[0]->name); ?> </a> <span class="separator">›</span> <?php endif; ?> <span> <?php the_title(); ?> </span> </div> </div> <section class="single-product-section"> <div class="single-product-layout"> <!-- Product Gallery --> <div class="product-gallery reveal"> <div class="product-main-image"> <?php if (has_post_thumbnail()): ?> <?php the_post_thumbnail('product-large'); ?> <?php else: ?> <svg width="120" height="120" fill="none" stroke="#ccc" stroke-width="1" viewBox="0 0 24 24"> <circle cx="12" cy="12" r="3" /> <path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" /> </svg> <?php endif; ?> </div> </div> <!-- Product Info --> <div class="product-info reveal"> <h1> <?php the_title(); ?> </h1> <div class="product-meta"> <?php if ($part_number): ?> <span>Part #: <?php echo esc_html($part_number); ?> </span> <?php endif; ?> <?php if ($categories && !is_wp_error($categories)): ?> <span> <?php echo esc_html($categories[0]->name); ?> </span> <?php endif; ?> </div> <div class="product-description"> <?php the_content(); ?> <?php if ($short_desc && empty(get_the_content())): ?> <p> <?php echo esc_html($short_desc); ?> </p> <?php endif; ?> </div> <!-- CTA Buttons --> <div class="product-actions"> <button class="btn btn-supply btn-lg" onclick="openModal('supply', '<?php echo esc_js(get_the_title()); ?>', '<?php echo esc_js($part_number); ?>')"> 🚚 Supply ASAP </button> <button class="btn btn-quote btn-lg" onclick="openModal('quote', '<?php echo esc_js(get_the_title()); ?>', '<?php echo esc_js($part_number); ?>')"> 📋 Get a Quote </button> </div> <div class="product-note"> <strong>How it works:</strong> Select "Supply ASAP" if you need this part dispatched immediately (paid via your account), or "Get a Quote" to receive pricing before ordering. </div> </div> </div> </section> <!-- Related Products --> <?php $related_args = array( 'post_type' => 'product', 'posts_per_page' => 4, 'post__not_in' => array(get_the_ID()), 'orderby' => 'rand', ); if ($categories && !is_wp_error($categories)) { $related_args['tax_query'] = array(array( 'taxonomy' => 'product_category', 'field' => 'term_id', 'terms' => $categories[0]->term_id, )); } $related = new WP_Query($related_args); if ($related->have_posts()): ?> <section class="related-products"> <div class="container"> <div class="section-header"> <span class="section-label">Related</span> <h2>Similar Products</h2> </div> <div class="products-grid"> <?php while ($related->have_posts()): $related->the_post(); ?> <div class="product-card reveal"> <a href="<?php the_permalink(); ?>" class="product-card-image"> <?php if (has_post_thumbnail()): ?> <?php the_post_thumbnail('product-thumb'); ?> <?php else: ?> <svg width="48" height="48" fill="none" stroke="#ccc" stroke-width="1.5" viewBox="0 0 24 24"> <circle cx="12" cy="12" r="3" /> <path d="M12 2v4M12 18v4" /> </svg> <?php endif; ?> </a> <div class="product-card-body"> <h3><a href="<?php the_permalink(); ?>" style="color:inherit;text-decoration:none;"> <?php the_title(); ?> </a></h3> <?php $pn = get_post_meta(get_the_ID(), '_ie_part_number', true); ?> <?php if ($pn): ?> <div class="part-number"> <?php echo esc_html($pn); ?> </div> <?php endif; ?> </div> <div class="product-card-actions"> <a href="<?php the_permalink(); ?>" class="btn btn-outline btn-sm">View Details</a> </div> </div> <?php endwhile; ?> </div> </div> </section> <?php endif; wp_reset_postdata(); ?> <?php get_footer(); ?>
cải xoăn