Hi
Add this to your child theme’s functions.php file:
/* PRODUCT BADGE
================================================== */
if ( ! function_exists( 'sf_woo_product_badge' ) ) {
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 apply_filters( 'woocommerce_sold_out_flash', '<span class="out-of-stock-badge">' . __( 'Sold', 'swiftframework' ) . '</span>', $post, $product);
} 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 }
}
– Kyle