Add sales end date to sales badge in WooCommerce

Add sales end date to sales badge in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

Snippet

add_filter( 'woocommerce_sale_flash', 'wc_sale_end_date', 9999, 3 );
 
function wc_sale_end_date( $html, $post, $product ) {
   if ( $product->get_date_on_sale_to() ) return $html . ' (ends ' . gmdate( 'd M', $product->get_date_on_sale_to()->getTimestamp() ) . ')'; 
   return $html;
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.