# Code prefixes: when the customer writes the code without the prefix

> For the administrator: register code prefixes so Dri finds the product when the customer writes only the number, such as 8020 instead of DV8020.

Source: https://vendria.com/en/ajuda/prefixos-de-codigo

## Where to find it

In your account menu, under **Order reading**, **Reading rules** tab, on the
**Code prefixes** card.

## What code prefixes are for

Code prefixes let Dri find the product when the customer writes only
the number. Many catalogs register products with a prefix (`DV8020`,
`CD8020`), and many customers write only the number: they ask for "8020" in a
message, in a photo of a list or in a spreadsheet. Without help, the row may
end up as "code not found".

With `DV` configured, an `8020` that doesn't exist in the catalog is also searched
as `DV8020`. If `DV8020` exists, the quote row is built with it. In a
price and stock lookup in the conversation, Dri shows the product and says that
she didn't find the exact code and found `DV8020` through the registered prefix.

Use it when your catalog has fixed prefixes and customers tend to leave them out.
If your codes have no prefix, leave the list empty: the card says that
no prefix is configured, and the search doesn't try any prefix.

## How to register code prefixes

1. Open **Order reading**, **Reading rules** tab, and find the
   **Code prefixes** card.
2. Type the prefix in the field (e.g. `DV`) and click **Add**, or press
   Enter. The prefix becomes a tag in the list.
3. Repeat for each prefix. To remove one, click the tag's **x**.
4. Click **Save**. The **Prefixes saved** message confirms it.

Nothing changes until you click **Save**: adding and removing tags only changes
the screen's draft.

The rules for a prefix:

- up to 12 characters, among letters, numbers and the separators period, underscore, hyphen and slash;
- at least **one letter**: a numbers-only prefix is rejected;
- at most 10 prefixes;
- lowercase letters become uppercase, and duplicates are discarded.

## Prefixes apply to the whole organization

The code prefix list belongs to **the organization**, not to the store selected in the
hub's selector. Any store you choose shows and edits the **same**
list, and each registered prefix is tested against the catalog of every store.

In practice: if store A uses `FJ` and store B uses `DV`, register both just
once. An `FJ8020` simply doesn't exist in store B's catalog, so the other
store's prefix doesn't get in the way.

## When the prefix kicks in

Four safeguards keep the prefix from swapping products:

1. It is tried only **after** the normal search has failed. No code that
   matches today starts pointing to another product.
2. A one-character code isn't expanded: it wouldn't identify anything.
3. If more than one prefix matches (for example, `DV8020` and `FJ8020` exist in
   both stores), the row becomes a **question with the options** for the seller
   to choose, never a silent guess.
4. If the code, as the customer wrote it, **really exists** on an
   active product of another store in the organization, the prefix isn't applied.
   In a single-store quote, the row becomes a question between the two
   products, instead of silently becoming another real product. See [Como a Dri encontra o produto que o cliente pediu](/ajuda/como-a-dri-encontra-o-produto).

## What the prefix doesn't fix

The prefix only **adds** the registered letters in front of what the customer
wrote. It doesn't swap, remove or correct letters:

- **Wrong or extra letters**: with `F` registered, `0189` is tried as `F0189`. But
  the prefix doesn't turn `JF0189` into `F0189`: it tries `FJF0189`, which doesn't
  exist.
- **Space in the middle of the code**: in a lookup in the conversation, *AB 10070*, with
  a space, isn't treated as a code, and the prefix doesn't kick in. Written together,
  *AB10070*, or just *10070*, works.
- **Word in front of the code**: in a lookup in the conversation, *reference
  10070* isn't treated as a code either. Send only the code.

In these cases, what works is sending **only the numbers**, or the whole code
exactly as it is in the catalog. For the seller, tips on how to write the
code are in [Consultar preço e estoque pelo WhatsApp](/ajuda/preco-e-estoque-pelo-whatsapp).

## With no prefix registered, the search still tries the fragment

When no prefix resolves it, the search still looks for codes that **contain** the
number the customer wrote. This is the fragment rescue, and it works even
with no prefix registered: `21465` is a piece of `CD21465`.

The difference from the prefix is what happens next:

- **In a lookup in the conversation**, Dri shows the product, saying *"This one
  contains that fragment:"*. With several, she lists the codes that contain the fragment.
- **In a quote**, the fragment never builds the row on its own: the row becomes an
  open question with the suggestions, none of them chosen, and the seller chooses.
- A fragment that appears in many products isn't suggested: it wouldn't
  identify anything.

The prefix is still worth it: it is a rule you
declared, and so it **builds the quote row directly** when only one product
matches. The fragment only suggests.

## When it goes wrong

**"I registered the prefix and the code is still not found."** Check that you clicked
**Save**, that the code with the prefix really exists in the catalog (search
`DV8020` in the product list) and that the product is active.

**"The screen rejected the prefix."** The rejection shows up when you click **Save**, and the
message says why: a prefix with no letter, or with a character other than letters,
numbers, period, underscore, hyphen and slash. The field doesn't accept more than 12
characters, and the **Add** button is disabled when the list already has 10
prefixes.

**"The row became a question instead of being built."** Two prefixes formed
codes that exist, or the code without a prefix is the code of a product in
another store of the organization. It's on purpose: choose the right product on the row.

**"The seller wrote the wrong letters and nothing was found."** The prefix doesn't correct
letters, it only adds the ones you registered. Ask them to send only the numbers,
or the whole code exactly as it is in the catalog.

**"Without the prefix registered, Dri found the product anyway."** That was the
fragment rescue: the number was a piece of a product's code. In the
conversation she shows the product saying the code wasn't exact; in a quote
she suggests, and the seller chooses.

## Common questions

**Do I need to register the prefix in each store?** No. The list belongs to the whole
organization and applies to the catalog of every store, whatever store is in the
selector.

**Can the prefix make a code that already works point to another product?**
No. It is tried only after the normal search has failed, and it isn't applied
when the written code already belongs to a product in another store of the organization.

**Does the prefix correct mistyped letters?** No. It only adds the
registered letters in front of what the customer wrote. With wrong letters, the
way out is sending only the numbers.

**If the search already finds it by the fragment, why register the prefix?** Because the
fragment only suggests, and the seller has to choose on each row. The prefix is
your rule: when only one product matches, the quote row comes out already built.
