if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
/**
 * The template to display product attributes on product page or with a shortcode
 *
 * Copy it to your theme implecode folder to edit the output: your-theme-folder-name/implecode/product-attributes.php
 *
 * @version		1.1.2
 * @package		ecommerce-product-catalog/templates/template-parts/product-page
 * @author 		Norbert Dreszer
 */
$single_names = get_single_names();
$product_id = ic_get_product_id();
$attributes_number = product_attributes_number();
$table = '';
if ($attributes_number > 0 && has_product_any_attributes($product_id)) {
    ?>
	<div id="product_features" class="product-features">
		<h3><?php 
    echo $single_names['product_features'];
    ?>
</h3>
		<table class="features-table"><?php 
    for ($i = 1; $i <= $attributes_number; $i++) {
        $attribute_value = get_attribute_value($i, $product_id);
        if (!empty($attribute_value)) {
            ?>
					<tr>
/**
 * Returns realted products
 *
 * @global object $post
 * @param int $products_limit
 * @param boolean $markup
 * @return string
 */
function get_related_products($products_limit = null, $markup = false)
{
    if (!isset($products_limit)) {
        $products_limit = apply_filters('related_products_count', get_current_per_row());
    }
    $current_product_id = ic_get_product_id();
    $taxonomy = get_current_screen_tax();
    $post_type = get_current_screen_post_type();
    $terms = get_the_terms($current_product_id, $taxonomy);
    if (is_array($terms) && !empty($taxonomy) && !empty($post_type)) {
        $terms = array_reverse($terms);
        $archive_template = get_product_listing_template();
        $i = 0;
        $inside = '';
        $products = array();
        foreach ($terms as $term) {
            $query_param = array('post_type' => $post_type, 'orderby' => 'rand', 'tax_query' => array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $term->slug)));
            $query = new WP_Query($query_param);
            while ($query->have_posts()) {
                $query->the_post();
                global $post;
                if ($current_product_id != $post->ID) {
                    $i++;
                    $products[] = $post->ID;
                }
                if ($i >= $products_limit) {
                    break;
                }
            }
            wp_reset_postdata();
            reset_row_class();
            if ($i >= $products_limit) {
                break;
            }
        }
        $div = '';
        if (!empty($products)) {
            $products = implode(',', $products);
            if ($markup) {
                $div = '<div class="related-products">';
                $single_names = get_single_names();
                if (!empty($single_names['other_categories'])) {
                    $div .= '<h2 class="catalog-header">' . $single_names['other_categories'] . '</h2>';
                }
                $div .= do_shortcode('[show_products product="' . $products . '"]');
                $div .= '</div>';
            } else {
                $div = do_shortcode('[show_products product="' . $products . '"]');
            }
        }
        return $div;
    }
    return;
}