How to Change the WooCommerce Price via Functions.php
Show a discounted price on WooCommerce products without editing the price in the database.
function return_custom_price($price, $product) { global $post, $blog_id; $price = get_post_meta($post->ID, '_regular_price'); $post_id = $post->ID; $price = ($price[0]*2.5); return $price; } add_filter('woocommerce_get_price', 'return_custom_price', 10, 2);
OR
function return_custom_price($price, $product) { global $post, $blog_id; $product = wc_get_product( $post_id ); $post_id = $post->ID; $price = ($price*2.5); return $price; } add_filter('woocommerce_get_price', 'return_custom_price', 10, 2);