<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( $related_products ) : ?>
		</div>
	</div>
</div>
<div>
	<div>
		<div>
<div class="product-related-section">
	<div class="ui basic secondary vertical segment">
		<div class="ui container">
			<div class="ui hidden section divider"></div>
			<div class="ui huge header"><?php esc_html_e('Related Products', 'campoal'); ?></div>
			<div class="title-divider"></div>
			<div class="ui hidden divider"></div>
			<div class="related-product-grid carousel-v1" data-column="three">
				<div class="<?php echo esc_attr(count($related_products) > 3 ? 'related-product ' : '') ?>ui three stackable cards">			
						
				<?php foreach ( $related_products as $related_product ) : ?>
					<?php
						$post_object = get_post( $related_product->get_id() );

						setup_postdata( $GLOBALS['post'] =& $post_object );
						
						if (count($related_products) > 3) { ?>
							<div>
						<?php } ?>
							<?php get_template_part('loop/content-product', 'carousel'); ?>
						<?php if (count($related_products) > 3) { ?>
							</div>
						<?php } ?>
				<?php endforeach; ?>

				</div>
			</div>
			<div class="ui hidden section divider"></div>
		</div>
	</div>
</div>
<?php endif;

wp_reset_postdata();