Enom TLD Price Importer Rounding To Nearest Dollar

ceopx

New Member
It's nice to see the upgrade to the TLD importer, where you can set the percentage markup.

However, a minor grievance is an inability to round to the nearest dollar i.e., $14.68 vs. $14.99. This keeps pricing consistent and professional with the rest of the e-commerce world.

This would require an extra user variable and a small modification to the important code:

User Setting
A) No rounding.
B) Round to the nearest dollar .99
C) Rounding to the exact dollar .00

Results
A) $11.75 @ 25% markup = $14.69 No rounding
B) $11.75 @ 25% markup = $14.99 Rounded up from $14.69
C) $11.75 @ 13% markup = $13.00 Rounded down from $13.28

Something like this...

PHP:
<?php
// Input cost
$cost = 100.75; // Replace this with your actual cost value

// Calculate markup
$markup = $cost * 0.25;

// Calculate retail price
$retail = round($cost + $markup);

// Round cents to the nearest dollar as .99
if ($retail % 100 != 99) {
    $retail = ceil($retail / 100) * 100 - 1;
}

// Output the result
echo "Cost: $" . number_format($cost, 2) . PHP_EOL;
echo "Markup: $" . number_format($markup, 2) . PHP_EOL;
echo "Retail: $" . number_format($retail, 2) . PHP_EOL;
?>
 
Back
Top