is_featured()): $badges .= '' . esc_html__('Featured', 'elessi-theme') . ''; endif; /** * New */ if (isset($nasa_opt['at_badge_new']) && $nasa_opt['at_badge_new']) : $product_id = $product->get_type() == 'variation' ? $product->get_parent_id() : $product->get_id(); $published_on = get_the_date('d-m-Y', $product_id); $current_date = strtotime(date('Y-m-d')); $target_date = strtotime($published_on); $diff_days = abs(floor(($target_date - $current_date) / (60 * 60 * 24))); $max_time = isset($nasa_opt['max_ns_time_at_badge_new']) && (int) $nasa_opt['max_ns_time_at_badge_new'] ? (int) $nasa_opt['max_ns_time_at_badge_new'] : 10; $badges .= $diff_days <= $max_time ? '' . esc_html__('New', 'elessi-theme') . '' : ''; endif; /** * On Sale Badge */ if ($product->is_on_sale()) : $badges_sale = ''; if ($product->get_type() == 'variable') : $badges_sale = '' . esc_html__('Sale', 'elessi-theme') . ''; else : $maximumper = 0; $regular_price = $product->get_regular_price(); $sale_price = $product->get_sale_price(); if (is_numeric($sale_price)) : $percentage = $regular_price ? round(((($regular_price - $sale_price) / $regular_price) * 100), 0) : 0; if ($percentage > $maximumper) : $maximumper = $percentage; endif; $badges_sale = '' . sprintf(esc_html__('-%s%', 'elessi-theme'), $maximumper) . ''; endif; endif; /** * Hook onsale WooCommerce */ $badges .= apply_filters('woocommerce_sale_flash', $badges_sale, $post, $product); /** * Style show with Deal product */ $badges .= '' . esc_html__('Limited', 'elessi-theme') . ''; endif; /** * Out of stock */ if ("outofstock" === $product->get_stock_status()): $badges .= elessi_badge_outofstock(); endif; /** * Backorders - Allowed */ if (isset($nasa_opt['backorder_badge']) && $nasa_opt['backorder_badge'] && $product->backorders_allowed()) : $badges .= '' . esc_html__('Backorders', 'elessi-theme') . ''; endif; /** * Hook to Badges */ $badges_content = apply_filters('nasa_badges', $badges); if ('' !== $badges_content) : echo '