Skip to main content

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

  1. Calculates the rounding difference for each category:
    • Items
    • Delivery
    • Payment
    • Discounts
    • Taxes
  2. Adds adjustment entries to round each category
  3. 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

SettingDefaultDescription
defaultPrecision5Round to nearest 5 cents
roundToStandard roundingReturns 0 if precision is 0

Adapter Details

PropertyValue
Keyshop.unchained.pricing.order-round
Version1.0.0
Order Index90
Sourcepricing/order-round.ts