Last active
April 10, 2024 12:45
-
-
Save JeroenSormani/489a82c0c250313f45ca to your computer and use it in GitHub Desktop.
WC disable sale on all products.
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
<?php | |
/** | |
* Disable all sales. | |
* | |
* A simple function to disable all the sales in the shop. | |
* Uncomment the line of code to disable the sale price on products. | |
*/ | |
function custom_wc_get_sale_price( $sale_price, $product ) { | |
// return $product->get_regular_price(); // Un-comment this to disable all sale prices | |
return $sale_price; | |
} | |
add_filter( 'woocommerce_product_get_sale_price', 'custom_wc_get_sale_price', 50, 2 ); | |
add_filter( 'woocommerce_product_get_price', 'custom_wc_get_sale_price', 50, 2 ); | |
// add_filter( 'woocommerce_get_sale_price', 'custom_wc_get_sale_price', 50, 2 ); // WC < 3.1.2 | |
// add_filter( 'woocommerce_get_price', 'custom_wc_get_sale_price', 50, 2 ); // WC < 3.1.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment