Skip to content

Instantly share code, notes, and snippets.

@mehedicsit
Forked from mikejolley/functions.php
Created March 21, 2018 14:05
Show Gist options
  • Save mehedicsit/010eebace378163a7ecfa60f81556bea to your computer and use it in GitHub Desktop.
Save mehedicsit/010eebace378163a7ecfa60f81556bea to your computer and use it in GitHub Desktop.
WooCommerce - Disable ALL sale prices with code
<?php
/**
* After adding this code to theme functions.php, ensure you clear transients via WC > System Status > Tools
*/
add_filter( 'woocommerce_get_sale_price', '__return_empty_string' );
add_filter( 'woocommerce_variation_prices_sale_price', '__return_empty_string' );
add_filter( 'woocommerce_variation_prices_price', 'custom_get_price', 10, 2 );
add_filter( 'woocommerce_get_price', 'custom_get_price', 10, 2 );
function custom_get_price( $price, $product ) {
if ( $product->is_type( 'variable' ) ) {
$prices = $product->get_variation_prices();
return min( $prices['regular_price'] );
} else {
return $product->get_regular_price();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment