'product',
'post__not_in' => array(get_the_ID()),
'posts_per_page'=> $related_no,
'author'=> get_the_author_meta( 'ID' )
);
} elseif ( $query_type == 'tag' ) {
$tags = get_the_terms( get_the_ID(), 'product_tag' );
$tags_ids = array();
foreach($tags as $tag) $tags_ids[] = $tag->term_id;
$args = array(
'post_type' => 'product',
'post__not_in' => array(get_the_ID()),
'posts_per_page'=> $related_no,
'tax_query' => array(
array (
'taxonomy' => 'product_tag',
'field' => 'id',
'terms' => $tags_ids,
)
),
);
} elseif ( $query_type == 'best_saller' ) {
$args = array(
'post_type' => 'product',
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'post__not_in' => array(get_the_ID()),
'posts_per_page' => $related_no,
);
} else {
$cats = get_the_terms( get_the_ID(), 'product_cat' );
$cats_ids = array();
foreach($cats as $cat) $cats_ids[] = $cat->term_id;
$args = array(
'post_type' => 'product',
'post__not_in' => array(get_the_ID()),
'posts_per_page'=> $related_no,
'tax_query' => array(
array (
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $cats_ids,
)
),
);
}
$posts = get_posts( $args );
$i = 0; ?>
is_on_sale() ) {
$badge_class = 'color2';
} else {
$badge_class = 'color1';
}
?>
is_on_sale() ) {
if (is_numeric( $product->get_regular_price() )) {
echo wp_kses_post( '-'.round( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 ).'%' );
}
} else {
esc_html_e( 'New', 'allo' );
}
?>