With this code, you can enter the price in the basket from an arbitrary field. But as soon as you set the format for displaying the price on the screen in the else container ( and only for simple goods ), the basket counts and sums up only the first digit of numbers (that is, thousands).
If the format in the else container does not specify the price, everything works like a clock, except that the screen displays an unformatted number instead of the normal price (only for a simple product !!!) . Variable goods can be formatted and displayed as you wish. Why? Is it possible not to override the price for display on the screen?
add_filter('woocommerce_get_price_html', 'sv_change_product_html', 10, 2 ); function sv_change_product_html( $price_html, $product ) { $rrp = get_post_meta( $product->id, 'rrp_price', true ); if ( ! empty( $rrp ) ) { $price_html = '<span class="amount">' . wc_price( $rrp ) .'</span>'; if($product->product_type=='variable') { $nrrp = number_format($rrp, 0, ',', ' '); $nrrp = 'от '. $nrrp; //$nrrp .= ' грн.'; return $nrrp; } else { $nrrp = number_format($rrp, 0, ',', ' '); $nrrp .= ' грн.'; return $nrrp; } return $rrp; } } function sv_change_product_price_cart( $price, $cart_item, $cart_item_key ) { $rrp = get_post_meta( $cart_item['product_id'], 'rrp_price', true ); if ( ! empty( $rrp ) ) { $price = wc_price( $rrp ); var_dump($price); } return $price; } add_filter( 'woocommerce_cart_item_price', 'sv_change_product_price_cart', 10, 3 );