Last active
December 29, 2018 16:50
-
-
Save Frique/4636b869fd17c33aaaae248cef4d8178 to your computer and use it in GitHub Desktop.
wcssm woocs support
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
// 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