OrderSummary

The OrderSummary component is a summary component that displays the total price of the order. You can use this component to show the total price of the order.

Props

className string?

The class name that is applied to the summary element. This prop is optional, and it defaults to an empty string.

fallback React.ReactNode?

A fallback component that is shown while the data is loading. This prop is optional, and it defaults to null.

OrderSummaryUIComponent React.ComponentType<OrderSummaryUIProps>?

A custom component that is used to render the order summary. This prop is optional, and it defaults to the OrderSummaryUI component. This component receives the necessary data to render the order summary.

Example

import { formatCentsWithCurrency } from "@firmhouse/firmhouse-sdk";

function CustomOrderSummaryUI({
  totalAmount,
  totalTaxAmount,
  cart,
  children,
  currency,
  t,
}) {
  return (  
    <div>
      <div>
        <p>{t?.("orderSummary.toPayNow")}</p>
        <p>
          <span>{t?.("orderSummary.subtotal")}</span>
          <span>
            {formatCentsWithCurrency(totalAmount, currency, locale ?? cart?.locale)}
          </span>
        </p>
        <p>
          <span>
            {t?.("orderSummary.shippingCost")}
          </span>
          <span>{t?.("orderSummary.free")}</span>
        </p>
        <p>
          <span>{t?.("orderSummary.total")}</span>
          <span>
            {formatCentsWithCurrency(totalAmount, currency, locale ?? cart?.locale)}
          </span>
        </p>
        <p>
          <span>
            {t?.("orderSummary.tax", {
              amount: formatCentsWithCurrency(
                totalTaxAmount ?? 0,
                currency,
                locale ?? cart?.locale
              ),
            })}
          </span>
        </p>
        {children}
      </div>
    </div>
  );
}

<OrderSummary OrderSummaryUIComponent={CustomOrderSummaryUI} />

Last updated