Order Price Rounding
Rounds all order pricing categories (items, delivery, payment, discounts, taxes) to a configurable precision. Typically runs last in the order pricing chain.
Installation
import '@unchainedshop/plugins/pricing/order-round';
How It Works
- Calculates the rounding difference for each category:
- Items
- Delivery
- Payment
- Discounts
- Taxes
- Adds adjustment entries to round each category
- Maintains tax proportions when rounding
Configuration
Configure the rounding behavior before starting the engine:
import { OrderPriceRound } from '@unchainedshop/plugins/pricing/order-round';
// Round to nearest 5 cents (default)
OrderPriceRound.configure({
defaultPrecision: 5,
});
// Round to nearest 10 cents
OrderPriceRound.configure({
defaultPrecision: 10,
});
// Disable rounding
OrderPriceRound.configure({
defaultPrecision: 0,
});
// Custom rounding function
OrderPriceRound.configure({
defaultPrecision: 5,
roundTo: (value, precision, currencyCode) => {
if (precision === 0) return value;
return Math.round(value / precision) * precision;
},
});
Default Settings
| Setting | Default | Description |
|---|---|---|
defaultPrecision | 5 | Round to nearest 5 cents |
roundTo | Standard rounding | Returns 0 if precision is 0 |
Adapter Details
| Property | Value |
|---|---|
| Key | shop.unchained.pricing.order-round |
| Version | 1.0.0 |
| Order Index | 90 |
| Source | pricing/order-round.ts |
Related
- Product Price Rounding - Round product prices
- Pricing System - Pricing overview