PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Rounding Syntax

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hello.

 

How can I edit the syntax for WOOBE to round differently than what is built in? I would like to round my prices in increments of 5 euros (5.00, 10.00, 15.00, 20.00, 425.00 Euros and so on) and in increments of 1 euros (1.00, 45.00, 32.00, 19.00 Euros). I found this in the domcumentation:

2
3
4
add_filter('woobe_number_field_manipulation', function($value, $field_key, $product_id) {
    //write your logic here
    return $value;
}, 10, 3);

But I do not know the syntax for the logic. Could I add these to the dropdown menu of the price rounding? Where there's 5, 99, 39 and so on to add 2 extra buttons? 500 and 100?

 

Thank you!

Hello

read  this  please - https://stackoverflow.com/questions/4133859/round-up-to-nearest-multiple-of-five-in-php

Could I add these to the dropdown menu of the price rounding? - Unfortunately, the plugin does not have such a feature, you need customization of the code

Ok, I see about the dropdown menu. But I am not fluent in php.

I would like to use the woobe_number_field_manipulation hook mentioned on this page of the documentation: https://bulk-editor.com/document/woocommerce-price-rounding/

How do I round to 5s or 1s with that? I know about the ceil and round functions, but what arguments should I round with these functions? Could you please help me out with this?

 

Thank you!

Hello

You  can  add this  code  in functions.php  ( Keep in mind I have not tested this code. )

add_filter('woobe_number_field_manipulation', function($value, $field_key, $product_id) {
 if($field_key=='sale_price' OR $field_key=='regular_price'){
 return (round($value)%5 === 0) ? round($value) : round(($value+5/2)/5)*5;
 }
    return $value;
}, 10, 3);