<figure class="product-transition"> <?php } } ?> <?php } else { ?> <figure> <?php } ?> <?php $image_html = ""; if (sf_is_out_of_stock()) { echo '<span class="out-of-stock-badge">' . __('Out of Stock', 'swiftframework') . '</span>'; } else { if ($product->is_on_sale()) { echo apply_filters('woocommerce_sale_flash', '<span class="onsale">' . __('Sale!', 'woocommerce') . '</span>', $post, $product); } else { if (!$product->get_price()) { echo '<span class="free-badge">' . __('Free', 'swiftframework') . '</span>'; } else { $postdate = get_the_time('Y-m-d'); // Post date $postdatestamp = strtotime($postdate); // Timestamped post date $newness = 7; // Newness in days if (time() - 60 * 60 * 24 * $newness < $postdatestamp) {
function sf_woo_product_badge() { global $product, $post, $sf_options; $postdate = get_the_time('Y-m-d'); // Post date $postdatestamp = strtotime($postdate); // Timestamped post date $newness = $sf_options['new_badge']; // Newness in days ?> <div class="badge-wrap"> <?php if (sf_is_out_of_stock()) { echo '<span class="out-of-stock-badge">' . __('Sold out', 'swiftframework') . '</span>'; } else { if ($product->is_on_sale()) { echo apply_filters('woocommerce_sale_flash', '<span class="onsale">' . __('Sale!', 'swiftframework') . '</span>', $post, $product); } else { if (time() - 60 * 60 * 24 * $newness < $postdatestamp) { // If the product was published within the newness time frame display the new badge echo '<span class="wc-new-badge">' . __('New', 'swiftframework') . '</span>'; } else { if ($product->get_price() != "" && $product->get_price() == 0) { echo '<span class="free-badge">' . __('Free', 'swiftframework') . '</span>'; } } } } ?> </div> <?php }