> For the complete documentation index, see [llms.txt](https://docs.samita.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.samita.io/sami-b2b-onboarding/integrations/existing-shopify-customers.md).

# Existing Shopify customers

Choose what an approval does when the buyer's email already belongs to a Shopify customer, and add tags to every customer a form approves.

Many wholesale buyers already shop at your store as retail customers. When you approve their application, Sami B2B Onboarding finds that customer by email instead of creating a second one. Each form's **Shopify** panel decides whether the approval keeps that customer's details or replaces them with the answers, and which extra tags the customer gets.

## When the app looks for the customer

Nothing is written to Shopify when a buyer submits. The app writes the customer when the application is approved, whether by someone on your team, by a rule or by a Shopify Flow workflow. It does the same when you add the buyer to a company you already have with **Add buyer**.

At that moment, the app:

1. Looks for a Shopify customer with the same email as the application. Upper and lower case don't matter, but the whole address must match.
2. Creates a customer from the mapped answers if there's none.
3. Applies **If the customer already exists** if there is one.
4. Marks the customer as approved either way: the **B2B approved** metafield is turned on and the tag `b2b-approved` is added.

A buyer who was signed in to their customer account when they applied is already linked to that account. Approving them uses that customer and marks them as approved, but leaves their details as they are and adds no other tags, whatever this setting says.

{% hint style="info" %}
Each application keeps the Shopify settings it was submitted with. A change you save applies to applications submitted after it, not to the ones already waiting.
{% endhint %}

## Choose what happens to an existing customer

{% stepper %}
{% step %}

### Open the Shopify panel

Go to **Forms** and click **Edit** beside the form. In the rail on the left, click **Integrations**. Under **Connected apps**, click **Manage** on the **Shopify** row.

The **Shopify** panel opens. Its first section, **Customer**, lists the answers that fill the customer, with two settings below them.
{% endstep %}

{% step %}

### Pick an option

In **If the customer already exists**, choose one of the options in the table below.

<figure><img src="https://3844812229-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRrf4pQPgjvb3GW7IN3Ci%2Fuploads%2Fgit-blob-7a58b54684b10f899967cff95807c7f761433147%2Fscreenshot-integrations-shopify-existing-customer.png?alt=media" alt="The Customer section of the Shopify panel, with Update with application data chosen and the tag wholesale added."><figcaption><p>These two settings, below the Customer rows, decide what approval does to the Shopify customer.</p></figcaption></figure>
{% endstep %}

{% step %}

### Save

Click **Save** in the save bar. You see **Form saved**.
{% endstep %}
{% endstepper %}

| Option                                    | What approval does to a customer who already exists                                                                                                                                                                                                  |
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Keep existing customer data** (default) | Links the application to the customer and changes nothing on them: not their name, phone, tags or metafields. No tags are added, not even the preset's or this panel's. They only get the approved flag and the `b2b-approved` tag.                  |
| **Update with application data**          | Writes the mapped first name, last name, phone and customer metafields over the customer's own. Adds the approval preset's tags, this panel's tags and any tags from answers, and keeps the tags the customer already had. The email doesn't change. |

{% hint style="warning" %}
If you rely on customer tags for discounts, theme rules or segments, choose **Update with application data**. With **Keep existing customer data**, buyers who already had an account don't get the preset's tags or the form's tags.
{% endhint %}

A new customer always gets everything: the mapped details and all the tags.

If Shopify refuses only the phone number, for example because of its format, the app saves the customer without it. The phone stays on the application.

## Add tags to every customer this form approves

{% stepper %}
{% step %}

### Turn on the tags

In the **Customer** section of the **Shopify** panel, tick **Add tags to the customer**. A tag box appears.
{% endstep %}

{% step %}

### Type the tags

Type a tag and press `Enter` or `,`. The box suggests tags your store's customers already have. The note under it reads **On top of the preset's tags. To tag from an answer, map a field to Tags (add).**
{% endstep %}

{% step %}

### Save

Click **Save** in the save bar.
{% endstep %}
{% endstepper %}

The tags go on every new customer this form approves. They go on existing customers only with **Update with application data**. To tag buyers by what they answered, map a field to **Tags (add)** or give a choice its own customer tags. See [Map answers to Shopify](/sami-b2b-onboarding/application-forms/map-answers-to-shopify.md).

## Separate billing address

The **Company location** section of the same panel has a **Separate billing address** box. It decides whether the company's first location gets its own billing address.

* **Off**: the billing address is the shipping address. Only the shipping fields are listed for mapping.
* **On**: the **Billing ·** fields are added to the list, so you can map your form's billing questions to them.

While any billing field is mapped, the box stays ticked and can't be cleared.

## What else the Shopify panel holds

| Section              | What it holds                                                                                                    |
| -------------------- | ---------------------------------------------------------------------------------------------------------------- |
| **Customer**         | The answers that fill the customer's email, name, phone, job title and tags, plus the two settings on this page. |
| **Company**          | The answers that fill the company's name, external ID, note and tags.                                            |
| **Company location** | The answers that fill the location's shipping and billing address.                                               |
| **Metafields**       | Answers saved in your own customer or company metafields.                                                        |

A note at the bottom reminds you where the rest comes from: **Activation email: Settings → Email. Catalog, payment terms and role: the preset chosen at approval.** The approval email itself, **Account approved**, is edited in the form builder's **Email** section. See [Edit email templates](/sami-b2b-onboarding/settings/email-templates.md). To set up the mapping, see [Map answers to Shopify](/sami-b2b-onboarding/application-forms/map-answers-to-shopify.md).

## Check what happened

After you approve, open the application in **Companies › Applications**. On its **Timeline**, click the **Shopify customer** entry to see the result:

| Result                                                                                                  | What it means                                                                   |
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| Created Shopify customer                                                                                | No customer had this email, so the app created one.                             |
| Matched an existing Shopify customer and kept its data                                                  | **Keep existing customer data** linked the existing customer.                   |
| Updated the existing Shopify customer with the application data                                         | **Update with application data** wrote the answers over the customer's details. |
| Shopify didn't create the customer, or Shopify didn't update the customer, followed by Shopify's reason | Shopify refused the change. The reason says which detail it didn't accept.      |

<figure><img src="https://3844812229-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRrf4pQPgjvb3GW7IN3Ci%2Fuploads%2Fgit-blob-f2b12cde34c5a92e3a134c964b9f64ee730acedc%2Fscreenshot-integrations-shopify-customer-timeline.png?alt=media" alt="The application&#x27;s Timeline with the Shopify customer entry open, reading Matched an existing Shopify customer and kept its data."><figcaption><p>The Shopify customer entry tells you whether the app created, kept or updated the customer.</p></figcaption></figure>

In the Shopify admin, go to **Customers** and open the buyer. The **B2B approved** metafield is on, and the `b2b-approved` tag is there.

## Next steps

* [Map answers to Shopify](/sami-b2b-onboarding/application-forms/map-answers-to-shopify.md) — choose which answers fill the customer, the company and its location.
* [Approval presets](/sami-b2b-onboarding/automation/approval-presets.md) — set the tags, catalog and terms an approval gives.
* [Approve an application](/sami-b2b-onboarding/reviewing-applications/approve-an-application.md) — see everything an approval does, step by step.
* [Block checkout until approved](/sami-b2b-onboarding/store-access/block-checkout-until-approved.md) — see how the approved flag lets the buyer check out.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.samita.io/sami-b2b-onboarding/integrations/existing-shopify-customers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
