Skip to content

Instantly share code, notes, and snippets.

@Frique
Created April 18, 2021 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Frique/8f2d8cc5f0402f6b00a88d5343856a5f to your computer and use it in GitHub Desktop.
Save Frique/8f2d8cc5f0402f6b00a88d5343856a5f to your computer and use it in GitHub Desktop.
WCSSM: Support for the Woodmart Countdown timer
// Force the native sale-price-end-date overwrite
add_filter( 'get_post_metadata', 'wcssm_woodmart_filter_sale_price_meta', 11, 4 );
function wcssm_woodmart_filter_sale_price_meta( $value, $object_id, $meta_key, $single ) {
if ( $meta_key === '_sale_price_dates_to' ) {
remove_filter( 'get_post_metadata', 'wcssm_woodmart_filter_sale_price_meta', 11, 4 );
if ( $sale = WCSSM::get_applicable_sale( $object_id ) ) {
$schedule = array_shift( $sale['schedule'] );
$value = $schedule['end'];
}
add_filter( 'get_post_metadata', 'wcssm_woodmart_filter_sale_price_meta', 11, 4 );
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment