This project is not covered by Drupal’s security advisory policy.
Commerce Rounding adds additional line item with rounding if you need to round the price to integers or to some certain amounts of cents.
It was inspired by the solution suggested by the Commerce authors, e.g. here.
This module defines its own price type and line item type rounding and two rules (enabled by default) to update the order rounding item after each update: commerce_rounding_apply and commerce_rounding_delete_rounding_line_items.
If you need different rounding algorithm, you can easily implement your own, by setting the commerce_rounding_function variable to your own function.
Example implementation of custom rounding algorithm:
// settings.php
$conf['commerce_rounding_function'] = 'commerce_rounding_value';
// your_custom.module
/**
* Default function for rounding value.
*
* @param int $total_price
* Total price
* @param string $currency_code
* Currency code
* @return int
* Positive or negative rounding
*/
function commerce_rounding_value($total_price, $currency_code) {
$residue = $total_price % 100;
if ($residue >= 50) {
$rounding = 100 - $residue;
}
else {
$rounding = -$residue;
}
return $rounding;
}
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: E-commerce
3 sites report using this module
- Created by wojtha on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.

