<?php
		$product = wc_get_product(get_the_ID());
		$post_date = get_the_date('Y-m-d', get_the_ID());
		$post_date_time = strtotime($post_date);
		$current_date_time = strtotime(current_time('Y-m-d'));
		$date_diff = ($current_date_time - $post_date_time) / (60 * 60 * 24);
		if ($date_diff <= 10){
			echo '<span class="badge new-label">NEW</span>';
		}
	?>
	<?php
		$max_discount = 0;
		$output = '';

		if ($product->is_type('variable')) {
			foreach ($product->get_available_variations() as $variation) {
				$regular_price_variation = $variation['display_regular_price'];
				$sale_price_variation = $variation['display_price'];
				if ($sale_price_variation < $regular_price_variation) {
					$percentage_off = round((($regular_price_variation - $sale_price_variation) / $regular_price_variation) * 100);
					if ($percentage_off > $max_discount) {
						$max_discount = $percentage_off;
					}
				}
			}
			if ($max_discount > 0) {
				$output = '<span class="badge sale">ON SALE</span>';
			}
		} else {
			$regular_price = (float) $product->get_regular_price();
			$sale_price = (float) $product->get_sale_price();
			if ($sale_price && $sale_price < $regular_price) {
				$output = '<span class="badge sale">ON SALE</span>';
			}
		}
		if($output){
			echo $output;
		}
	?>