> For the complete documentation index, see [llms.txt](https://wishlist.nativeappco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wishlist.nativeappco.com/customisation/custom-widgets-in-the-drawer.md).

# Custom Widgets in the Wishlist Drawer

Add sign-up forms, loyalty points and other app widgets to the wishlist drawer using the embed codes your apps already give you.

The wishlist drawer is a great place for more than wishlists. Shoppers open it when they're interested in your products, so it's a natural spot for a newsletter sign-up, loyalty points, a VIP tier or a promotion.

If an app gives you an **embed code** or a **JavaScript snippet** to place its widget on your store, you can almost always place that widget in the wishlist drawer too.

{% hint style="info" %}
This requires some edits to your theme code. If you need help, please [Contact Us](mailto:undefined), or ask your AI agent to do it for you with [Fish Wishlist's MCP connection](https://wishlist.nativeappco.com/install-and-setup/installing-using-ai-tools/connect-with-mcp.md).
{% endhint %}

### How it works

The wishlist drawer is ordinary HTML on your storefront. It isn't in an iframe or hidden away from the rest of the page, so:

* other apps' scripts can find and fill elements inside it, just like anywhere else on your page;
* your CSS reaches it, so you can style the widget to match the drawer.

Most apps give you an embed code: an empty placeholder element, such as `<div class="klaviyo-form-ABC123"></div>`. The app's script finds the placeholder when the page loads and draws its widget inside it.

So the method is always the same:

1. Add the app's embed code to your theme, as you would anywhere else.
2. Move it into the wishlist drawer with a few lines of JavaScript.

Moving an element keeps everything the app has drawn inside it, so it doesn't matter whether the app renders before or after the move.

{% hint style="info" %}
This guide is for **Wishlist Drawer 2.0**. See [Switching to Wishlist Drawer 2.0](https://wishlist.nativeappco.com/install-and-setup/theme-setup/switching-to-wishlist-drawer-2-0.md) if you're still on the classic drawer.
{% endhint %}

### Where you can place a widget

| Placement                               | Add your widget to                          | Good for                          |
| --------------------------------------- | ------------------------------------------- | --------------------------------- |
| Under the drawer header, always visible | The drawer panel, right after `.fw2-header` | Loyalty progress bars, promotions |
| Lists tab                               | `fw2-drawer .fw2-pane--lists`               | Sign-up forms for guests, banners |
| Account tab                             | `fw2-drawer .fw2-pane--account`             | Points balance, VIP tier, rewards |

{% hint style="warning" %}
Add your widget **directly** to the elements above. Don't put it inside `fw2-sign-in`, `fw2-account`, `.fw2-lists` or `.fw2-tabs`: Fish Wishlist redraws those as shoppers use the drawer, and your widget would disappear.
{% endhint %}

### Add a widget step by step

{% stepper %}
{% step %}

### Copy the app's embed code

In the app you want to show, look for an option such as **Embed**, **Install on site**, **Display on-site** or **Developer code**. Copy the HTML it gives you.
{% endstep %}

{% step %}

### Create a snippet in your theme

In Shopify Admin, go to **Online Store** > **Themes**, then **Actions** > **Edit code**. In the **Snippets** folder, add a new snippet called `fish-drawer-widgets` and paste:

```liquid
<div id="fish-drawer-widget" class="fish-drawer-widget" hidden>
  <!-- Paste the app's embed code here -->
</div>

<script>
  (function () {
    // Moves the widget into the wishlist drawer's Lists tab
    function moveWidget() {
      var widget = document.getElementById('fish-drawer-widget');
      var pane = document.querySelector('fw2-drawer .fw2-pane--lists');
      if (!widget || !pane) return;
      pane.prepend(widget);
      widget.hidden = false;
    }

    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', moveWidget);
    } else {
      moveWidget();
    }
  })();
</script>
```

* The widget starts `hidden` so it doesn't flash at the bottom of the page, and is shown once it's in the drawer.
* `pane.prepend(widget)` puts it at the top of the tab, and `pane.append(widget)` at the bottom.
* For the Account tab, use `.fw2-pane--account` instead of `.fw2-pane--lists`.
  {% endstep %}

{% step %}

### Render the snippet in your theme

Open `layout/theme.liquid` and add this line just before `</body>`:

```liquid
{% render 'fish-drawer-widgets' %}
```

{% endstep %}

{% step %}

### Style it

In Fish Wishlist, go to **Settings** and add styles for your widget under **Additional CSS**, for example:

```css
fw2-drawer .fish-drawer-widget {
  margin: 12px 0;
}
```

{% endstep %}

{% step %}

### Test it

Open the drawer as a guest and as a logged-in customer, on desktop and mobile. Check the widget shows where you expect and still works (for example, that a form submits).
{% endstep %}
{% endstepper %}

***

### Example: Klaviyo sign-up form for guests

Invite shoppers who aren't logged in to join your mailing list, right under the drawer's sign-in prompt.

1. In Klaviyo, go to **Sign-up forms**, create an **Embed** form and publish it.
2. Copy its embed code. It looks like `<div class="klaviyo-form-ABC123"></div>`.
3. Use this as your `fish-drawer-widgets` snippet, replacing `ABC123` with your form's ID:

```liquid
{% unless customer %}
  <div id="fish-drawer-klaviyo" class="fish-drawer-widget" hidden>
    <div class="klaviyo-form-ABC123"></div>
  </div>

  <script>
    (function () {
      // Puts the form right under the drawer's sign-in prompt
      function moveForm() {
        var form = document.getElementById('fish-drawer-klaviyo');
        var pane = document.querySelector('fw2-drawer .fw2-pane--lists');
        if (!form || !pane) return;
        var signIn = pane.querySelector('fw2-sign-in');
        if (signIn) signIn.after(form);
        else pane.prepend(form);
        form.hidden = false;
      }

      if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', moveForm);
      } else {
        moveForm();
      }
    })();
  </script>
{% endunless %}
```

`{% unless customer %}` shows the form to guests only.

{% hint style="info" %}
Klaviyo's script must be on your store: it is when the Klaviyo app embed is turned on in your theme. If the form doesn't appear, check that it is published in Klaviyo.
{% endhint %}

#### Going further: a "Join Now" button

If you'd rather keep the drawer clean, add a **Join Now** button next to the sign-in prompt that opens the form in a pop-up or slide-out from your theme instead.

* Close the wishlist drawer before opening your pop-up, so it isn't hidden behind the drawer: `document.querySelector('fw2-drawer').close()`.
* Klaviyo tells the page when a form is submitted. Listen for it to bring the shopper back to their wishlist:

```javascript
window.addEventListener('klaviyoForms', function (event) {
  if (event.detail.type !== 'submit' || event.detail.formId !== 'ABC123') return;
  // Close your pop-up here, then reopen the wishlist drawer
  document.querySelector('fw2-drawer').openTab('lists');
});
```

***

### Example: loyalty points and rewards

Show logged-in customers their points balance, VIP tier or progress to the next reward. This example uses Yotpo Loyalty; other loyalty apps such as Smile.io, LoyaltyLion, Rivo or influence.io work the same way with their own embed code.

1. In Yotpo, go to **Loyalty & Referrals** > **Display on-site**, choose the widget you want to show, and copy its embed code. It looks like `<div class="yotpo-widget-instance" data-yotpo-instance-id="123456"></div>`.
2. Use this as your `fish-drawer-widgets` snippet:

```liquid
{% if customer %}
  <div id="fish-drawer-loyalty" class="fish-drawer-widget" hidden>
    <div class="yotpo-widget-instance" data-yotpo-instance-id="123456"></div>
  </div>

  <script>
    (function () {
      // Puts the loyalty widget at the top of the drawer's Account tab
      function moveLoyalty() {
        var loyalty = document.getElementById('fish-drawer-loyalty');
        var pane = document.querySelector('fw2-drawer .fw2-pane--account');
        if (!loyalty || !pane) return;
        pane.prepend(loyalty);
        loyalty.hidden = false;
      }

      if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', moveLoyalty);
      } else {
        moveLoyalty();
      }
    })();
  </script>
{% endif %}
```

`{% if customer %}` shows it to logged-in customers only, as points belong to an account.

#### Under the greeting in the Account tab

<figure><img src="https://1134778209-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMp2ekCAtVgFUnsQlGWfX%2Fuploads%2Fgit-blob-7ded244adcffb2bf1024a64665f5b83fa8e504bd%2Fdrawer-widget-loyalty-account.png?alt=media" alt="A loyalty card with points and reward progress in the wishlist drawer&#x27;s Account tab"><figcaption><p>A loyalty card under the greeting in the Account tab</p></figcaption></figure>

To place the widget between the greeting and the rest of the account, as above, it goes inside the account dashboard. Fish Wishlist redraws the dashboard (for example when a customer opens an order and comes back), so the script keeps hold of the widget and puts it back each time. Use this `moveLoyalty` in the snippet above:

```javascript
// Keeps the loyalty widget right under the Account tab's greeting
function moveLoyalty() {
  var loyalty = document.getElementById('fish-drawer-loyalty');
  var account = document.querySelector('fw2-drawer fw2-account');
  if (!loyalty || !account) return;
  loyalty.hidden = false;

  function place() {
    var greeting = account.querySelector('.fw2-greeting');
    if (greeting && greeting.nextElementSibling !== loyalty) greeting.after(loyalty);
  }

  // Runs again whenever the dashboard is redrawn
  new MutationObserver(place).observe(account, { childList: true });
  place();
}
```

#### Under the header on the Lists tab

To show a progress bar under the drawer header instead, while the Lists tab is open, use this `moveLoyalty` in the snippet above:

```javascript
// Puts the loyalty widget right under the drawer header
function moveLoyalty() {
  var loyalty = document.getElementById('fish-drawer-loyalty');
  var header = document.querySelector('fw2-drawer .fw2-header');
  if (!loyalty || !header) return;
  header.after(loyalty);
  loyalty.hidden = false;
}
```

Then hide it on the Account tab with **Additional CSS**:

```css
fw2-drawer:has(.fw2-pane--lists.is-hidden) .fish-drawer-widget {
  display: none;
}
```

{% hint style="success" %}
**Already showing loyalty in your cart drawer?** Many themes have a loyalty or free-shipping progress bar in the cart. Render the same snippet inside your `fish-drawer-widgets` holder to show it in the wishlist drawer too, with the same look.
{% endhint %}

#### Widgets added after the page loads

Some apps only draw widgets that are on the page when it first loads. Because the snippet above adds the embed code in your theme and only moves it, this is already taken care of.

If you build a widget's HTML in JavaScript instead, ask the app to draw it afterwards. Most apps have a function for this; for Yotpo it's:

```javascript
if (window.yotpoWidgetsContainer && typeof window.yotpoWidgetsContainer.initWidgets === 'function') {
  window.yotpoWidgetsContainer.initWidgets();
}
```

***

### Tips

* **Guests and customers:** wrap your embed in `{% if customer %}` or `{% unless customer %}` to choose who sees it.
* **Pop-ups from other apps** can open behind the wishlist drawer. Close the drawer first with `document.querySelector('fw2-drawer').close()`.
* **Keep your code in your theme snippet.** Don't edit Fish Wishlist's own files: your snippet keeps working when the app updates.
* **Several widgets:** give each one its own holder `id`, and move each one in the same script.
