# Worked examples

Source: https://developer.avalara.com/products/self-serve-tariff-code/integration-guides/classyvue-integration-guide/ioy1174624174295/

Guide: ClassyVue integration guide

# Worked examples

Examples of classification requests and results for import and export scenarios, including HTSUS, Schedule B, and Combined Nomenclature codes.

These are a few working examples.

## Example 1: US import (HTSUS)

Returns the 10-digit HTSUS import code for goods arriving in the U.S..

```
ccce.classify(
  { product: 'cotton t-shirt', destination: 'US', origin: 'IN' },
  onClassifyComplete
);
```

## Example 2: US export (Schedule B)

Returns the 10-digit Schedule B code filed in AES/EEI for goods shipping out of the U.S..

```
ccce.classify(
  {
    product: 'cotton t-shirt',
    destination: 'US',
    origin: 'IN',
    lang: 'EN-US',
    importMode: false
  },
  onClassifyComplete
);
```

## Example 3: Germany export (Combined Nomenclature)

Returns the 8-digit CN code filed on an EX-A export declaration in Germany.

```
ccce.classify(
  {
    product: 'wireless bluetooth headphones',
    destination: 'DE',
    origin: 'CN',
    lang: 'DE',
    importMode: false
  },
  onClassifyComplete
);
```

## Example 4: Side-by-side import and export codes

Many integrations need both codes for the same SKU. Issue 2 `classify()` calls with the same product description:

```
// Import-side: HTSUS for goods arriving in the US
ccce.classify(
  { product: 'cotton t-shirt', destination: 'US', origin: 'IN' },
  onImportDone
);
// Export-side: Schedule B for the same goods leaving the US
ccce.classify(
  { product: 'cotton t-shirt', destination: 'US', origin: 'IN', importMode: false },
  onExportDone
);
```

## **Example 5: Handling the result**

The `data-on-complete` handler (or the callback passed to `classify()`) receives an object describing the classification the user confirmed. A simplified example:

```
function onClassifyComplete (result) {
  // result.code         -- final code at native digit length
  // result.hs6          -- universal 6-digit HS root
  // result.schedule     -- 'HTSUS' | 'ScheduleB' | 'CN' | 'TARIC' | ...
  // result.country      -- 'US' | 'DE' | ...
  // result.description  -- official tariff description
  // result.importMode   -- echoes the value used for the request
  saveToCatalog({
    sku:      currentSku,
    hs6:      result.hs6,
    exportCd: result.code,           // Schedule B / CN / ...
    schedule: result.schedule
  });
}
function onClassifyAbort (context) {
  // User closed the widget before completing classification
  console.log('classification cancelled', context);
} 
```

## Example 6: End-to-end embed example (US Schedule B)

```

  Schedule B Demo 
    #my-classifier { width: 100%; height: 640px; }

 Get a Schedule B code Classify product  
    window.onClassifyComplete = function (r) {
      console.log(&#39;Schedule B result:&#39;, r);
    };
    window.onClassifyAbort = function (c) {
      console.log(&#39;cancelled&#39;, c);
    };
    window.runClassify = function () {
      ccce.classify({
        product:     &#39;cotton t-shirt&#39;,
        destination: &#39;US&#39;,
        origin:      &#39;IN&#39;,
        lang:        &#39;EN-US&#39;,
        importMode:  false
      }, window.onClassifyComplete, window.onClassifyAbort);
    };

```

## Quick reference card

Goal

Code snippet

US import (HTSUS)

`{ destination: 'US', importMode: true }`

US export (Schedule B)

`{ destination: 'US', importMode: false }`

DE import (TARIC)

`{ destination: 'DE', importMode: true }`

DE export (Combined Nomenclature)

`{ destination: 'DE', importMode: false }`

Universal 6-digit HS (no country)

`{ hs6: true }`