Skip to content

Instantly share code, notes, and snippets.

@bulentsakarya
Last active December 19, 2019 11:34
Show Gist options
  • Save bulentsakarya/c13a5ef654ce0883e9b8d07ac447f64d to your computer and use it in GitHub Desktop.
Save bulentsakarya/c13a5ef654ce0883e9b8d07ac447f64d to your computer and use it in GitHub Desktop.
woocommerce new badge for new products
add_action( 'woocommerce_before_shop_loop_item_title', '_new_badge_shop_page', 3 );
function _new_badge_shop_page() {
global $product;
$gun = 30; // Etiket son 30 günde eklenen ürünlere eklenecek
$eklenme_tarihi = strtotime( $product->get_date_created() ); // Ürünün eklenme tarihi
if ( ( time() - ( 60 * 60 * 24 * $gun ) ) < $eklenme_tarihi ) {
echo '<span class="yeni onsale">' . esc_html__( 'Yeni!', 'wootemasi' ) . '</span>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment