Round numbers
Select how to round float values fractions in the numeric fields – round numeric meta values. Sometimes it is necessary to specify rounding precision when changing prices and its possible with calculator so with Bulk Edit tab functionality.
Let’s consider way with calculator. You can use this way if all the posts meta field you want to change is visible on one page:
- select posts you need using checkboxes
- enable ‘binded editing‘
- click on calculator on the cell you need, for example let it be price cell (hover mouse pointer on the cell to see calculator icon)
- enter natural value or percentage and select ‘rounding‘ there
- press accept button and wait until data set finished
Second way allows set rounding prices for filtered posts or all posts on the site (in this case do not filter posts). For example:
- filter posts by any category using functionality of tab Filters (or skip this step)
- go to Bulk Edit tab
- in ‘numeric‘ section enable ‘price‘ field and set value there
- and then select cents rounding as on the screen below
- click on ‘Do Bulk Edit‘ button and wait until operation is finished
Information about rounding behavior:
- no rounding – rounding will not be applied
- 5 – prices will be rounded to numbers like: 23.75, 44.45, 11.15
- 10 – prices will be rounded in numbers like: 23.70, 44.40, 11.10
- 9 … 99 – will round prices in numbers like: 23.09, 44.49, 11.99
Also, if it’s necessary to realize your own rounding logic it is possible to use hook ‘wpbe_number_field_manipulation‘:
add_filter('wpbe_number_field_manipulation', function($value, $field_key, $post_id) { //write your logic here return $value; }, 10, 3);
This hook you can find in the plugin code: wp-content\plugins\bulk-editor\classes\models\posts.php
The code above you should apply in file functions.php of your current WordPress theme.