# Multiplying & Rounding

Hi folks, this question relates to a Wordpress function, but as it’s still php specific i thought it would be better posted here.

Basically i’m drawing in a csv into woocommerce and during upload i am running a custom function on the price field to convert my trade price to retail price.

So on the csv import field i run this

which calls this function

[php]function price_mod(\$price,\$number) {
return \$price*\$number;
}[/php]

In theory it works but i would love someone to help me expand it.

Basically it is giving me results like £12.753 & £16.724 etc etc … So you can see my problem.

What i would like is for it to always round up to the nearest .99

So £12.753 would become £12.99 ---- £16.724 would become £16.99.

I don’t know if this is at all possible, nor am i really a coder.

Any help would be greatly appreciated.

Everything is possible, the impossible just takes a little longer to implement.

Something like this should work

[php]<?php

function roundPrice (\$unrounded) {
return round(\$unrounded) - 0.01;
}

\$numbers = array(
12.753,
16.724,
15
);

foreach (\$numbers as \$number) {
echo roundPrice(\$number) . ‘
’;
}[/php]

Output:

```12.99 16.99 14.99```

[hr]

Or if you want the clean integer (15 / 15.0000) to be rounded up to 15.99

[php]<?php

function roundPrice (\$unrounded) {
return round(\$unrounded) == round(\$unrounded, 2)? \$unrounded + 0.99 : round(\$unrounded) - 0.01;
}

\$numbers = array(
12.753,
16.724,
15
);

foreach (\$numbers as \$number) {
echo roundPrice(\$number) . ‘
’;
}[/php]

Output:

```12.99 16.99 15.99```

Thanks so much for your reply ! That looks like what i want to achieve, but i have no idea how to tie it in with my Wordpress Custom Function, which multiplies the value first …

I am pretty dumb when it comes to this stuff !