Skip to content

Instantly share code, notes, and snippets.

@Frique
Last active December 29, 2018 16:50
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/4636b869fd17c33aaaae248cef4d8178 to your computer and use it in GitHub Desktop.
Save Frique/4636b869fd17c33aaaae248cef4d8178 to your computer and use it in GitHub Desktop.
wcssm woocs support
// Scheduled Sale Manager for WooCommerce support for Currency Switcher for WooCommerce by RealMag777
// Prevents incorrect sale price when the "Advanced > Is multiple allowed" option is enabled.
if ( class_exists( 'WOOCS' ) ) {
global $WOOCS;
add_filter( 'woocommerce_product_get_price', function( $price, $product_object ) {
global $WOOCS;
$is_manual_sale = $product_object->get_sale_price( 'edit' ) && $product_object->get_sale_price( 'edit' ) == WCSSM::get_product_sale_price( $product_object->get_sale_price( 'edit' ), $product_object );
if ( $WOOCS->is_multiple_allowed && $product_object->is_on_sale() && ! $is_manual_sale ) {
remove_filter( 'woocommerce_product_get_price', array( $WOOCS, 'raw_woocommerce_price' ), 9999, 2 );
}
return $price;
}, 9998, 2 );
add_filter( 'woocommerce_product_get_price', function( $price, $product_object ) {
global $WOOCS;
$is_manual_sale = $product_object->get_sale_price( 'edit' ) && $product_object->get_sale_price( 'edit' ) == WCSSM::get_product_sale_price( $product_object->get_sale_price( 'edit' ), $product_object );
if ( $WOOCS->is_multiple_allowed && $product_object->is_on_sale() && ! $is_manual_sale ) {
add_filter( 'woocommerce_product_get_price', array( $WOOCS, 'raw_woocommerce_price' ), 9999, 2 );
}
return $price;
}, 10000, 2 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment