> For the complete documentation index, see [llms.txt](https://galmis.gitbook.io/barcodify-customer-selector/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://galmis.gitbook.io/barcodify-customer-selector/getting-started/bring-your-customer-barcodes-to-the-app/use-a-customer-metafield-as-barcode.md).

# Use a customer metafield as barcode

## Sync customer barcodes from a metafield

If your customer barcodes already live in Shopify — for example, imported from a loyalty platform, POS system, or a previous app — you don't need to re-enter them manually. Barcodify can automatically sync barcodes directly from a customer metafield, so your existing data becomes scannable right away.

Once enabled, the app reads the value stored in the metafield you choose and uses it as each customer's barcode. Any time the metafield is updated, the barcode stays in sync automatically.

A few things to know before you enable this feature:

* <mark style="color:$warning;">**Metafield values overwrite custom barcodes.**</mark> If you've saved custom barcodes directly in Barcodify (via [Admin](/barcodify-customer-selector/getting-started/bring-your-customer-barcodes-to-the-app/enter-barcodes-in-admin.md), [POS](/barcodify-customer-selector/getting-started/bring-your-customer-barcodes-to-the-app/enter-barcodes-in-pos.md) or the [import](/barcodify-customer-selector/getting-started/bring-your-customer-barcodes-to-the-app/import-barcodes.md)), syncing from a metafield will replace them with the metafield's value.
* **Use a single-value metafield.** The selected metafield must store one value per customer (not a list) — types like single line text, integer, or ID work well.
* **Duplicate protection is available.** You can optionally skip updates when a barcode is already assigned to another customer, preventing two customers from sharing the same barcode.
* **Sync runs periodically**. If you've just enabled the setting, it may take some time for the app to sync all of the store's customers. Once the app "catches up", new metafield updates should be quickly processed (generally, within a few minutes).&#x20;

## Setup instructions

To begin syncing customer barcodes automatically, first enable the feature in your app settings:

1. Navigate to the **Settings** section of the app.
2. Check the box for **Automatically sync barcodes from a customer metafield**.

<figure><img src="/files/A2TxuWv56kIZc1ewALrx" alt=""><figcaption></figcaption></figure>

3. *(Optional)* Check **Skip update if the barcode is already used by another customer** to prevent duplicate barcode assignments. Note: if using structured metafields, **I recommend using Unique values only validation** to prevent duplicates.

<figure><img src="/files/cYROZFjzq3FzFRLSFCFJ" alt=""><figcaption></figcaption></figure>

#### Option 1: Select an Existing Structured Metafield

If you have already defined a structured customer metafield in Shopify, follow these steps to link it:

1. Click into the **Search metafields** input box.
2. Under the **Structured metafields** list, select your desired metafield definition (e.g., `custom.dummy_barcode_example` as seen in the example.&#x20;

   <figure><img src="/files/o6liRydhCLshJbUlCV68" alt=""><figcaption></figcaption></figure>
3. Click **Save**.

#### Option 2: Create and Select a New Metafield Definition

If you haven't created a metafield in Shopify yet, you can build one directly through the app:

1. Click into the **Search metafields** input box.
2. Under Structured metafields, select **Create metafield definition**.&#x20;

   <figure><img src="/files/orfsmRyLm1NhEuHpw1g4" alt=""><figcaption></figcaption></figure>
3. In the setup modal, configure your new metafield:
   * Name: Give your metafield a clear title (e.g., `Barcode`).
   * Type: Choose a single-value format such as Single line text, Integer, or ID.
   * Validation: I highly recommend checking **Unique values only** to ensure two customers don't accidentally share the same barcode.
   * Other: Learn more about [creating custom metafield definitions](https://help.shopify.com/en/manual/custom-data/metafields/metafield-definitions/creating-custom-metafield-definitions).
4. Click **Save** inside the modal. The newly created definition will be automatically selected for you.&#x20;

   <figure><img src="/files/LfRdzHxfM0UVnHryg0Ls" alt=""><figcaption></figcaption></figure>
5. Click **Save** on the app's settings page.

#### Option 3: Add an Unstructured Metafield Manually

If you are using legacy, unstructured metafields that don't appear in the standard dropdown list, you can connect them manually:

1. Click into the **Search metafields** input box.
2. Scroll to the **Unstructured metafields** section at the bottom of the dropdown and select **Add metafield manually**.&#x20;

   <figure><img src="/files/tqiD4IlFqgrrJIdsISwU" alt=""><figcaption></figcaption></figure>
3. In the pop-up modal, enter the exact namespace and key of your existing customer metafield using the `namespace.key` format (for example: `dummy.barcode`).&#x20;

   <figure><img src="/files/D1HxAsg7xqQcdlCpSGBZ" alt=""><figcaption></figcaption></figure>
4. Click **Add** to confirm the metafield selection.
5. Click **Save** on the app's settings page.

## Test

1. Create or update a customer.
2. Validate that the value in the customer's metafield appears in the **Custom barcode** text field on the app's customer profile.

<figure><img src="/files/gBQtBuJbDWlms10201Hz" alt=""><figcaption></figcaption></figure>

The same principle works in Shopify POS (available to the POS Pro locations only), e.g. you can add the barcode value to the associated metafield when creating/updating the customer profile. Learn more about [customer metafields in Shopify POS](https://help.shopify.com/en/manual/sell-in-person/shopify-pos/customer-management/metafields).

<figure><img src="/files/OHuIpWDVAvUUQ5l0gKvk" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
Barcodes stored in metafields overwrite custom barcodes saved directly in [Admin](/barcodify-customer-selector/getting-started/bring-your-customer-barcodes-to-the-app/enter-barcodes-in-admin.md), [POS](/barcodify-customer-selector/getting-started/bring-your-customer-barcodes-to-the-app/enter-barcodes-in-pos.md) or via the [import](/barcodify-customer-selector/getting-started/bring-your-customer-barcodes-to-the-app/import-barcodes.md).&#x20;

If you're interested in updating barcodes directly in the app and via the metafield sync, please contact me at <hello@galmis.com>. I will add the feature if there's enough demand for it.
{% endhint %}
