Skip to content

Instantly share code, notes, and snippets.

@JeroenSormani
Last active April 10, 2024 12:45
Show Gist options
  • Save JeroenSormani/489a82c0c250313f45ca to your computer and use it in GitHub Desktop.
Save JeroenSormani/489a82c0c250313f45ca to your computer and use it in GitHub Desktop.
WC disable sale on all products.
<?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