> ## Documentation Index
> Fetch the complete documentation index at: https://www.twicecommerce.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to identify stock items with stock codes and barcodes

> Give each unit a code you can scan, and understand why a stock code and a listing barcode are different things that resolve differently.

<Card title="Open in TWICE Admin" icon="external-link" href="https://admin.twicecommerce.com/inventory/stock-items" horizontal>
  inventory/stock-items
</Card>

Two different things in TWICE can be scanned, and readers routinely conflate them:

* A **stock code** identifies **one unit**. Scanning it takes you to that unit's page. This is what you put on the asset tag.
* A **listing barcode** identifies **a listing** — the thing you sell, not a unit of it. Scanning it takes you to the listing.

They live on different objects, on different tabs, and they answer different questions. "Which bike is this?" is a stock code. "What is this product, so I can add it to an order?" is a listing barcode.

This guide covers giving units codes and knowing what a scan will do. For what each identifier is in the data model, see [Stock Codes](/docs/concepts/inventory/stock-codes) and [Listing barcodes](/docs/catalog/listings/barcodes).

## Prerequisites

<Warning>
  **Required permissions:**

  * `inventory:stock_item:create` — codes set while registering
  * `inventory:stock_item:manage` — codes changed afterwards

  All four system roles hold both.
</Warning>

<Info>
  **Before you start, decide how you generate codes.** Auto-generated codes are unique and consistent and need no thinking. Your own codes are worth it when the unit already carries an identifier you cannot change — a manufacturer serial, an existing asset tag, a number stencilled on the hull. Mixing both across a fleet is fine; mixing both on one unit is not, because a unit's codes are one list.
</Info>

## The Walkthrough

<Steps>
  <Step title="Set codes when you register">
    In the **Register new stock item** dialog, **Item Codes** decides where the codes come from:

    * **Auto-generate** — TWICE creates them. **Quantity** then decides how many units you get.
    * **Manual** — you type them. The **Quantity** field disappears, because the number of codes you enter *is* the number of units. Three codes, three units.

    That swap catches people out: with manual codes there is no separate quantity to set.
  </Step>

  <Step title="Add or change codes on an existing unit">
    A stock item can carry more than one code — useful when a unit already has a supplier's label and you want your own alongside it. Both resolve to the same unit when scanned.

    Open the item and edit its codes on the **General** tab.
  </Step>

  <Step title="Put the code on the physical unit">
    A code that only exists in the database does not save anyone time. Print it, stick it on the unit, and put it where a picker will actually look — not on a part that gets removed, and not somewhere that will be scuffed off in a season.

    Document templates can render a barcode, so the label can come out of TWICE rather than a separate tool.
  </Step>

  <Step title="Scan it">
    Scanning works **anywhere in the admin**, without a scan field to focus first. TWICE watches for scanner input, looks the code up, and navigates.

    Two exceptions worth knowing:

    * **Order pages have their own scanner.** On an order, scanning adds and assigns items to that order rather than navigating away — which is what you want while picking.
    * **Scanning is ignored while you are typing in a field.** Click out of the input first, or the code lands in the text box.
  </Step>

  <Step title="Know what a scan will resolve to">
    One scanned string is checked against three things at once, and TWICE goes to the first match in a fixed order:

    | Order | What it matches            | Where it takes you     |
    | ----- | -------------------------- | ---------------------- |
    | 1     | A **stock code** on a unit | That stock item's page |
    | 2     | A **listing barcode**      | That listing's page    |
    | 3     | An **order reference**     | That order             |

    So if the same string is both a stock code and a listing barcode, **the stock item wins** — the listing is never reached. Worth knowing before you reuse manufacturer barcodes as stock codes.

    Order matching is looser than the other two on purpose: it matches the full reference *and* the bare number, so scanning `42` finds the order whose reference shows as `#42`.
  </Step>
</Steps>

## How do I know it worked?

* **Scanning the label opens the unit's page** — not a search result, not a list. A scan that resolves navigates.
* **A code that does not resolve says so:** *No match found for scanned code: {'{code}'}*, in a notification. That message means TWICE read the scanner fine and found nothing, which is a different problem from the scanner not working at all.
* **The code is on the item's General tab**, and on all of the item's codes if it carries several.

## Troubleshooting / Common Pitfalls

<AccordionGroup>
  <Accordion title="Scanning does nothing at all">
    **Most likely: focus.** Scanning is deliberately ignored while an input, textarea, or editable field has focus, so a scan into a form field goes into the field. Click on empty page space and scan again.

    **Or you are on an order page.** Orders run their own scanner, which adds items to the order rather than navigating. That is the intended behaviour while picking, not a fault.
  </Accordion>

  <Accordion title="&#x22;No match found for scanned code&#x22;">
    **The scan worked; the lookup found nothing.** Codes are matched **exactly**, after trimming surrounding whitespace — no partial or fuzzy matching.

    **What to do:** search the inventory table for the code as text. If it is not there, the unit does not carry that code. If it is there but the scan fails, compare them character for character — a scanner configured to add a prefix, suffix, or carriage return produces a string that no longer matches the stored code.
  </Accordion>

  <Accordion title="Scanning a barcode opens a stock item when I wanted the listing">
    **Working as designed, and this is the resolution order biting.** Stock codes are checked before listing barcodes, so a string that is both resolves to the unit.

    **What to do:** keep the two namespaces apart. If you reuse manufacturer barcodes as listing barcodes, do not also use them as stock codes — give units their own codes, auto-generated or prefixed.
  </Accordion>

  <Accordion title="I set codes manually and got the wrong number of units">
    **Cause:** with **Manual** codes, the number of codes is the number of units. The **Quantity** field is hidden precisely because the code list already answers it.

    **What to do:** count the codes before submitting. If you wanted five units, enter five codes.
  </Accordion>

  <Accordion title="A scan takes me to the wrong unit of the same model">
    **Cause:** the code is not unique, or the label went on the wrong unit. TWICE returns the first match, so a duplicated code always resolves to the same one of the pair.

    **What to do:** find both units and re-code one. Auto-generated codes avoid this by construction, which is the main argument for using them on stock that has no external identifier of its own.
  </Accordion>

  <Accordion title="Which one goes on the shelf label, and which on the unit?">
    **The unit gets the stock code. The shelf, bin, or product label gets the listing barcode.**

    A picker holding an item asks "which unit is this" — stock code. Someone at a counter adding a product to an order asks "what is this" — listing barcode. Labelling them the other way round works right up until you need to tell two identical units apart, which is the entire point of individual tracking.
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Stock Codes" icon="barcode" href="/docs/concepts/inventory/stock-codes">
    What a stock code is in the data model.
  </Card>

  <Card title="Listing barcodes" icon="tag" href="/docs/catalog/listings/barcodes">
    The other identifier, and where it lives.
  </Card>

  <Card title="Register stock items" icon="plus" href="/docs/guides/inventory/register-stock-items">
    Where codes are first set.
  </Card>

  <Card title="Bulk-edit stock items" icon="pen-to-square" href="/docs/guides/inventory/bulk-edit-stock-items">
    Changing identifiers across many units at once.
  </Card>
</CardGroup>
