Overwrite prices in catalog and product page

/**
 * Overwrite Sale price with custom price
 */
function overwrite_sale_price_with_custom_price ( $price, $product ) {
	if ( $custom_price ) :
		$price = wc_format_sale_price( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ), $product->get_meta('_custom_price') ) .
		$product->get_price_suffix();
	endif;

	return $price;
}
add_filter( 'woocommerce_get_price_html', 'overwrite_sale_price_with_custom_price', 10, 2 );

Leave a Reply

Your email address will not be published.