DOCS

Totals element

/

Totals element

Learn how to display landed cost as an itemized cart breakdown with the Totals element.

The Totals element allows you to display a complete breakdown of each line item that goes into a landed cost calculation. This includes the item price, shipping cost, duties and taxes, and any other fees that are included in the landed cost calculation. The Totals element is a great way to show your customers exactly what they're paying for and why.

Zonos totals element example

1

Import the Zonos SDK

React
Vanilla JavaScript

First, install the Zonos Elements package in your React project. This will automatically add the Zonos SDK as a peer dependency, and includes TypeScript typings out of the box for a better developer experience.

Terminal

1
npm install --save @zonos/zonos-elements-react
2

Configure the Zonos SDK

React
Vanilla JavaScript

Once the Zonos Elements package is installed, you can configure the Zonos SDK in your React project. You need to have a Zonos account and API key to use Elements on your site.

The Elements React library exposes a ZonosProvider component that you can use to configure the Zonos SDK. You can wrap your entire application in the ZonosProvider component, or you can wrap only the components that use the Zonos SDK. We recommend storing your Zonos API key in an environment variable and passing it to the ZonosProvider component as a prop for security reasons.

App.js

1
2
3
4
5
6
7
import { ZonosProvider } from '@zonos/zonos-elements-react';

export const App = () => (
  <ZonosProvider config={{ apiKey: process.env.REACT_APP_ZONOS_API_KEY }}>
    {/* The rest of app goes here */}
  </ZonosProvider>
);
3

Create a Totals element

React
Vanilla JavaScript

To create a Totals element, use the Totals component from the Zonos Elements React library. You will need to pass in a LandedCost object from the Zonos API, which will be automatically formatted and displayed as an itemized breakdown, complete with localized currency.

JavaScript

1
2
3
4
5
6
7
8
9
10
11
import { Totals } from '@zonos/zonos-elements-react';

export const YourComponent = () => (
  <div>
    {/* The rest of your component goes here */}
    <Totals
      landedCost={/* Reference to your landed cost object here */}
    />
    {/* The rest of your component goes here */}
  </div>
);

Zonos totals element example

Was this page helpful?


© 2023 Zonoszonos.com