Last active
April 19, 2021 11:20
-
-
Save Spirecool/7f965db3772ec899d2a6d8aadab9287b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_before_shop_loop_item_title', 'popcorn_new_badge_shop_page', 3 ); // on commence par la position où va se trouver le badge, puis on créé une fonction | |
function popcorn_new_badge_shop_page() { | |
global $product; | |
$newness_days = 30; //ici on met le nombre jours, nouveautés sur les 30 derniers jours dans ce cas présent | |
$created = strtotime( $product->get_date_created() ); | |
if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) < $created ) { | |
echo '<span class="itsnew onsale">' . esc_html__( 'Nouveauté!', 'woocommerce' ) . '</span>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment