> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.tyslo.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# EasySell: how to insert the form button

# EasySell: how to insert the form button (guide for AI agents)

Audience: AI agents that build Shopify landing pages, product pages, or theme sections for stores that use the EasySell COD form.

Goal: put the EasySell order button (or the form itself) at the exact place you want in your markup.

You only write HTML. EasySell finds the markers below when it starts, and does the rest. Do not load EasySell scripts yourself and do not copy EasySell's own button markup.

---

## 1. Quick decision



The merchant chooses the form type (popup or embedded) in the EasySell app. You cannot see it from the page markup. If you do not know it, use section 8.

**Popup form**

- EasySell's own styled button at a chosen place: Method A (section 3).
- Your own button, link, or image that opens the form: Method B (section 4).
- Several buttons, each with its own quantity or variant: section 9.
- Open the form from your own JavaScript: Method D (section 6).

**Embedded form**

- The form rendered inline at a chosen place: Method A (section 3).
- An extra button that scrolls down to the form: Method C (section 5).

**No code**

- The merchant adds app blocks in the theme editor: Method E (section 7).

---

## 2. Requirements

1. The EasySell app embed is enabled in the theme. Without it, nothing below works.
2. The form is enabled for this page type and this product in the EasySell app settings.
3. The markers are in the HTML when the page loads. EasySell scans the page once when it starts. It does not see markers that you inject later with JavaScript.
4. The page has a product that EasySell can resolve. See section 9.

---

## 3. Method A: hook placeholder (EasySell renders the button)

Put this empty placeholder where the button must appear:

```html
<span id="es-form-hook"></span>
```

Page builders that only accept a link can use an anchor placeholder. All three anchors below are valid. Use anchors also when you need more than one button on a page, because an id must be unique.

```html
<a href="es-form-hook"></a>
<a href="/es-form-hook"></a>
<a href="es-popup-form-hook"></a>
```

What happens:

- **Popup form:** EasySell inserts its button directly after every placeholder, then removes the placeholder. The button style comes from the EasySell Form Builder. A click opens the popup form.
- **Embedded form:** EasySell moves the whole form directly after the first **es-form-hook** placeholder. The **es-popup-form-hook** anchor is ignored in embedded mode.

Rules:

- Always write the span with a closing tag, as in the snippet above. Do not write it self-closing in plain HTML. HTML does not self-close a span, so the content after it goes inside the span, and EasySell deletes that content together with the placeholder. JSX is fine, because it outputs a real closing tag.
- Keep the placeholder empty.
- EasySell's CSS hides the anchor placeholders, so they never show as links.
- The inserted button takes the width of its container. Put the placeholder in a container that has the width and alignment you want.
- The inserted button has the id and the class **es-popup-button**. Do not rely on more of its structure than that.

Example:

```html
<section class="hero">
  <h1>Product name</h1>
  <p class="price">$29.00</p>
  <div class="hero__cta">
    <span id="es-form-hook"></span>
  </div>
</section>
```

---

## 4. Method B: overwrite button (your own element opens the popup)

Use this method when you want full control of the design. You write the button. EasySell only adds the click behaviour. This method works with the popup form only.

Mark your element in one of three ways: a class (use this for several buttons on one page), an id (one element only), or a link target (for page builders that only accept a URL).

```html
<button type="button" class="es-popup-button-overwrite">Order now</button>

<button type="button" id="es-popup-button-overwrite">Order now</button>

<a href="#es-popup-button-overwrite">Order now</a>
```

Rules:

- The element stays as you wrote it. EasySell adds a pointer cursor and a click listener. It adds no other style.
- Inside a form element, give the button the type "button", as in the snippet. A submit button also submits the theme's add-to-cart form.
- For the link, the href value must start with the hash sign, exactly as in the snippet.
- The click target can be a child of the marked element. An icon or a span inside the button works.
- Optional animation: add the **data-animation** attribute with one of these values: shake, bounce, pulse, tada. EasySell reads the attribute from the first overwrite element on the page and applies it to all of them.
- Overwrite buttons work on product, home, and regular pages. They do not work on the cart page.
- In embedded mode these elements do nothing. See section 8.

Example with an animation:

```html
<button type="button" class="es-popup-button-overwrite my-cta" data-animation="pulse">
  <span>Order now</span>
  <small>Pay on delivery</small>
</button>
```

---

## 5. Method C: scroll button (embedded form only)

This method adds a button that scrolls smoothly to the inline form. It is good for a CTA at the top of a long landing page.

```html
<a href="es-scroll-button" title="Order now"></a>
```

What happens: EasySell replaces the anchor with a copy of the form's submit button, with the same style. The title attribute becomes the button text. Without a title, the button keeps the text of the form's submit button.

Rules:

- Embedded form only. In popup mode the anchor stays hidden and does nothing.
- It does not work on the cart page.
- You can use several anchors on one page.
- The href value can also start with a slash.

---

## 6. Method D: open the popup from JavaScript

In popup mode, EasySell exposes a global function after it starts:

```js
if (typeof window.openTysloForm === 'function') {
  window.openTysloForm();
}
```

Rules:

- The function does not exist in embedded mode, and it does not exist before EasySell starts. Always keep the guard.
- Prefer Method B when a click on an element is sufficient. Method B also tells EasySell which product form the click came from.
- To open the popup automatically on page load, add the parameter **easysell=1** to the page URL. Popup mode only.

---

## 7. Method E: theme editor app blocks (no code)

On Online Store 2.0 themes, the merchant can add these blocks in the theme editor, on product, home, page, and cart templates:

- **EasySell Form / Button:** marks the place for the form (embedded mode) or the button (popup mode). It has a Product setting. Set it when the page is not a product page, so EasySell knows which product to sell.
- **Extra Button (Optional):** adds one more button. In popup mode it opens the form. In embedded mode it scrolls to the form.

If the EasySell Form / Button block is on the page, the embedded form renders inside that block, and the hook placeholders do not change the form position.

---

## 8. Markup that works for both form types

If you do not know the merchant's form type, use the markup below. The marker for the other mode stays invisible.

At the main position, where the form or the main button must be:

```html
<span id="es-form-hook"></span>
```

- Popup: it becomes the EasySell button.
- Embedded: the form renders here.

At each extra CTA position (hero, sticky bar, bottom of the page):

```html
<a href="es-popup-form-hook"></a>
<a href="es-scroll-button" title="Order now"></a>
```

- Popup: the first anchor becomes the EasySell button. The second stays hidden.
- Embedded: the first stays hidden. The second becomes the scroll button.

Do not use an overwrite button (Method B) as the only CTA unless you know that the form type is popup. In embedded mode it stays visible, and a click does nothing.

---

## 9. Which product, variant, and quantity the form uses

**Product**

- On a product template, EasySell uses the page's product. This is the most reliable setup for a landing page.
- On other pages (home, regular pages), EasySell needs a product source. The sources are, in order: the EasySell Form / Button block with its Product setting, a PageFly or GemPages product element, or a product JSON script tag whose id starts with "ProductJson" or "product-json". Without one of these, EasySell has no product to add.

**Variant and quantity**

EasySell reads both values from the add-to-cart form that contains the clicked button. The form needs two inputs: one with the name "id" for the variant id, and one with the name "quantity".

- If the form has no quantity input, the quantity is 1.
- If the button is not inside a form, EasySell uses the variant parameter of the URL, then the theme's variant picker, then the first product form on the page.

So the rule is: put each button inside the form that holds its variant and its quantity.

```html
<form method="post" action="/cart/add">
  <input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
  <input type="hidden" name="quantity" value="1">
  <!-- variant picker here -->
  <span id="es-form-hook"></span>
</form>
```

### One button per offer (different quantity or variant per button)

Use this when the page shows several offers, for example "Buy 1", "Buy 2", "Buy 3", and each offer has its own button. This works with the popup form.

Give each offer its own form. Put the variant id and the quantity of the offer in hidden inputs, and put the button inside the form. On a click, EasySell opens the popup with the values of that form.

```html
<script>window.ES_IS_PAGEBUILDER = true;</script>

<form method="post" action="/cart/add">
  <input type="hidden" name="id" value="VARIANT_ID">
  <input type="hidden" name="quantity" value="1">
  <button type="button" class="es-popup-button-overwrite">Buy 1</button>
</form>

<form method="post" action="/cart/add">
  <input type="hidden" name="id" value="VARIANT_ID">
  <input type="hidden" name="quantity" value="2">
  <button type="button" class="es-popup-button-overwrite">Buy 2</button>
</form>

<form method="post" action="/cart/add">
  <input type="hidden" name="id" value="VARIANT_ID">
  <input type="hidden" name="quantity" value="3">
  <button type="button" class="es-popup-button-overwrite">Buy 3</button>
</form>
```

For one button per variant (for example one button per color), use the same markup and change the variant id in each form.

Rules:

- The form must have the post method and an action that contains "/cart/add", as in the snippet. EasySell does not find other forms.
- Replace VARIANT_ID with the numeric Shopify variant id. In Liquid, output the id of the variant.
- The button can be your own element (Method B) or a hook placeholder (Method A). Both work inside the form.
- Your own button must have the type "button". Without it, the click also submits the form to the Shopify cart.
- Keep the script of the first line. These forms are add-to-cart forms, so without it EasySell also adds its automatic button to the first form. See section 10.
- If you change the variant or the quantity with JavaScript, update the value attribute of the input (use setAttribute). EasySell reads the attribute first.
- A visible quantity input or a variant select element inside the form also works. The names must be "quantity" and "id".

Limits:

- If the merchant enabled the quantity field inside the EasySell form, that field sets the quantity, and the quantity of your form is ignored.
- If the merchant configured EasySell quantity offers for the product, the popup selects the offer that has the same quantity as the clicked button. If the merchant marked one offer as preselected, that offer stays selected.
- With the embedded form there is only one form on the page, so one button per offer does not apply. The embedded form follows the variant and the quantity of the page's product form.

---

## 10. Automatic placement and duplicate buttons

In popup mode, EasySell also places a button automatically. It uses the first of these elements that exists on the page:

1. The EasySell Form / Button app block
2. A PageFly add-to-cart element
3. An element with the id "new-form"
4. The theme's buy-buttons element
5. The Shopify dynamic checkout button
6. The submit button of the add-to-cart form
7. A button with a data-product-id attribute
8. The end of the add-to-cart form

So a page that has a standard add-to-cart form and your marker shows two buttons: the automatic one and yours. A page with none of these elements gets no automatic button, and you need nothing more.

EasySell skips the automatic button only when both conditions are true:

- The page has a hook span (Method A), the **es-popup-form-hook** anchor, or an overwrite element marked by class or by id.
- The page is a page-builder page. EasySell detects PageFly and GemPages automatically.

For a custom page, declare it as a page-builder page. Put this script in the page body. It must run before EasySell starts, so do not add defer, async, or the module type.

```html
<script>window.ES_IS_PAGEBUILDER = true;</script>
```

Notes:

- The **es-form-hook** anchor and the overwrite link (Method B, link form) do not stop the automatic button. Use the span, the class, the id, or the **es-popup-form-hook** anchor.
- To keep the automatic button together with yours on a page-builder page, set this flag in the same way:

```html
<script>window.ES_ALLOW_HOOK_DUPLICATE = true;</script>
```

---

## 11. Common mistakes

- **No button appears.** The app embed is off, or the form is not enabled for this page or product. Ask the merchant to check the EasySell app settings.
- **No button appears, and the settings are correct.** JavaScript added the marker after page load. Put the marker in the initial HTML.
- **The content after the hook disappears.** The span is self-closing in plain HTML. Write it with a closing tag.
- **Two buttons appear.** The automatic placement and your marker are both active. See section 10.
- **Your own button does nothing.** The form type is embedded. Use the markup of section 8.
- **Your own link does nothing.** The href value has no hash sign. See section 4.
- **A click also adds to cart or reloads the page.** Your button is inside a form and has no type "button".
- **The form shows the wrong variant or quantity.** The button is outside the form that holds the variant and quantity inputs, or the form has no post method. See section 9.
- **All offer buttons open with the same quantity.** The buttons share one form, or the EasySell form has its own quantity field. See section 9.
- **The scroll button does not appear.** The form type is popup, or the page is the cart page. This is the expected behaviour.

---

## 12. Summary of the markers

- **Hook span and es-form-hook anchors (section 3).** Popup: EasySell button. Embedded: form position.
- **es-popup-form-hook anchor (section 3).** Popup: EasySell button. Embedded: ignored.
- **Overwrite class, id, or link (section 4).** Popup: your element opens the form. Embedded: no effect.
- **es-scroll-button anchor (section 5).** Popup: ignored. Embedded: button that scrolls to the form.
- **openTysloForm function and easysell=1 URL parameter (section 6).** Popup only.
- **ES_IS_PAGEBUILDER and ES_ALLOW_HOOK_DUPLICATE flags (section 10).** They control the automatic button in popup mode.