Created
April 18, 2021 12:30
-
-
Save Frique/8f2d8cc5f0402f6b00a88d5343856a5f to your computer and use it in GitHub Desktop.
WCSSM: Support for the Woodmart Countdown timer
This file contains 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
// 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