I found this thread in wordpress http://wordpress.org/support/topic/get-woocommerce-scheduled-sale-end-date?replies=15
but when I tried it, it did not work. Perhaps because the answer was too old.
Anyone knows how to get end date of scheduled sale woocommerce product?
This is what I have so far
$sale_price_dates_to = ( $date = get_post_meta( $thepostid, '_sale_price_dates_to', true ) ) ? date_i18n( 'Y-m-d', $date ) : '';
echo $sale_price_dates_to;
it returns
string(0) ""
Thanks
An example on this page, details how it can be done:
Add the following to the functions.php
file
add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
function custom_price_html( $price, $product )
{
global $post;
$sales_price_to = get_post_meta($post->ID, '_sale_price_dates_to', true);
if(is_single() && $sales_price_to != "")
{
$sales_price_date_to = date("j M y", $sales_price_to);
return str_replace( '</ins>', ' </ins> <b>(Offer till '.$sales_price_date_to.')</b>', $price );
}
else
{
return apply_filters( 'woocommerce_get_price', $price );
}
}
I have tried it on my website and it works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With