If you want to display the value entered by the user in a number field in price format, you can use this snippet:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display the value of a specific field as a price | |
* Update the field_id to match your own field ID | |
*/ | |
function demo_display_value_as_price( $value, $item ) { | |
if( $item['field_id'] == '1047' && $item['type'] == 'number' ) { | |
$value = wc_price( $value ); | |
} | |
return $value; | |
} | |
add_filter( 'pewc_filter_item_value_in_cart', 'demo_display_value_as_price', 10, 2 ); |