<?php
/**
 * Related Products
 *
 * Template aligned with WooCommerce 9.6.0
 * @see https://woocommerce.com/document/template-structure/
 * @package Pawfect
 * @version 10.9.1
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

if ( $related_products ) : ?>
    <section class="related products pawfect-related-products">
        <?php $heading = apply_filters( 'woocommerce_product_related_products_heading', __( 'Related products', 'pawfect' ) );
        if ( $heading ) : ?>
            <h2 class="pawfect-text-3xl md:pawfect-text-4xl lg:pawfect-text-5xl pawfect-font-bold pawfect-leading-tight pawfect-mb-6"><?php echo esc_html( $heading ); ?></h2>
        <?php endif; ?>
        <?php woocommerce_product_loop_start(); ?>
            <?php foreach ( $related_products as $related_product ) :
                $post_object = get_post( $related_product->get_id() );
                setup_postdata( $GLOBALS['post'] = $post_object ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited, Squiz.PHP.DisallowMultipleAssignments.Found
                wc_get_template_part( 'content', 'product' );
            endforeach; ?>
        <?php woocommerce_product_loop_end(); ?>
    </section>
<?php endif;
wp_reset_postdata();

