Last active
July 14, 2019 00:39
-
-
Save stevenhoney/5c4a3e8e0bb6a60b3eaffd984607b042 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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