Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stevenhoney/5c4a3e8e0bb6a60b3eaffd984607b042 to your computer and use it in GitHub Desktop.
Save stevenhoney/5c4a3e8e0bb6a60b3eaffd984607b042 to your computer and use it in GitHub Desktop.
add_filter( 'woocommerce_get_price_html', 'sale_ends_banner', 100, 2 );
function sale_ends_banner( $price_html, $product ){
$sales_price_to = get_post_meta( $product->id, '_sale_price_dates_to', true );
if( $sales_price_to ){
$date_less_day = date_sub( $date, date_interval_create_from_date_string( "1 day") );
$formatted_date = date( 'l jS F', $date_less_day );
return $price_html."<p>Hurry! Sale Ends ".$formatted_date."</p>" ;
} else {
return $price_html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment