This tutorial adds a prompt to the Prestige cart drawer. When a shopper clicks Remove, they can save that item to their wishlist first. Yes saves it, then removes it from the cart. No removes it without saving. If saving fails, the item stays in the cart.

The example uses Prestige’s line-item-quantity and cart-drawer elements. Check your theme version’s markup before editing, and adapt the selectors for another theme. Work in a duplicate theme, test it, then publish it.

Before you start

  • Install Wishlist Power and enable its app embed in Online Store → Themes → Customize → App embeds.
  • Confirm that your theme uses a cart drawer with a Remove link for each item.
  • In Online Store → Themes → Edit code, find the Remove link. In Prestige it is in snippets/line-item.liquid, inside <line-item-quantity> and uses line_item.url_to_remove.

1. Add the prompt to the line item

In snippets/line-item.liquid, insert this immediately after the closing </line-item-quantity> that contains the Remove link:

{%- if wishlist_remove_prompt -%}
  <div class="wl-remove-prompt v-stack justify-items-start gap-2"
       data-wl-save-error="{{ 'cart.wishlist.save_error' | t | escape }}"
       data-wl-login-required="{{ 'cart.wishlist.login_required' | t | escape }}"
       hidden>
    <p class="text-xs">{{ 'cart.wishlist.question' | t }}</p>
    <div class="h-stack gap-2">
      <ooo-wl-wishlist-button
        product-id="{{ line_item.product_id }}"
        handle="{{ line_item.product.handle }}"
        variant-id="{{ line_item.variant_id }}"
        loading>
        <button type="button" class="button button--sm">
          <span class="ooo-wl-wishlist-button-add">{{ 'cart.wishlist.yes' | t }}</span>
        </button>
      </ooo-wl-wishlist-button>
      <button type="button" class="button button--sm button--outline" data-wl-remove-prompt="no">
        {{ 'cart.wishlist.no' | t }}
      </button>
    </div>
    <p class="text-xs" data-wl-remove-status role="status" hidden></p>
  </div>
{%- endif -%}

The prompt must be the next element after <line-item-quantity>; the script uses that relationship to find the original Remove link. variant-id identifies the cart item’s variant. In product mode, Wishlist Power may save the whole product instead of the variant.

In sections/cart-drawer.liquid, add wishlist_remove_prompt: true to the render call for drawer line items. Preserve any other arguments already present:

{%- render 'line-item', line_item: line_item, show_quantity_selector: true, wishlist_remove_prompt: true -%}

This keeps the prompt out of the full cart page if the snippet is shared.

2. Add the text and visibility styles

Inside the cart object in locales/en.default.json, add a wishlist object. Merge these keys with existing entries and keep the JSON commas valid:

"wishlist": {
  "question": "Save this product to your wishlist?",
  "yes": "Yes",
  "no": "No",
  "save_error": "We couldn't confirm that this item was saved. It is still in your cart. Please try again.",
  "login_required": "Sign in to save this item to your wishlist. It is still in your cart."
}

Add the same keys to your other theme locales. Add this CSS to your assets/theme.css stylesheet so theme display rules do not override hidden:

cart-drawer line-item-quantity[hidden],
cart-drawer .wl-remove-prompt[hidden],
cart-drawer .wl-remove-prompt [hidden] {
  display: none !important;
}

cart-drawer .wl-remove-prompt ooo-wl-wishlist-button[loading] {
  visibility: hidden;
}

3. Add the interaction script

Create assets/wishlist-cart-remove-prompt.js with this code:

(() => {
  const REMOVE_LINK = 'cart-drawer line-item-quantity > a[href*="/cart/change"], cart-drawer line-item-quantity > a.aca-cco';
  const INNER_REMOVE_LINK = ':scope > a[href*="/cart/change"], :scope > a.aca-cco';
  const YES_BUTTON = 'cart-drawer .wl-remove-prompt ooo-wl-wishlist-button button';
  const NO_BUTTON = 'cart-drawer .wl-remove-prompt [data-wl-remove-prompt="no"]';

  function removeFromCart(prompt) {
    const link = prompt.previousElementSibling?.querySelector(INNER_REMOVE_LINK);
    if (!link) return;
    prompt.querySelectorAll('button').forEach(button => { button.disabled = true; });
    link.dataset.wlConfirmed = 'true';
    link.click(); // Let the theme update the cart drawer.
  }

  function showError(prompt, message) {
    const status = prompt.querySelector('[data-wl-remove-status]');
    status.textContent = message;
    status.hidden = false;
    prompt.querySelector('[data-wl-remove-prompt="no"]')?.removeAttribute('disabled');
  }

  document.addEventListener('click', event => {
    if (!(event.target instanceof Element)) return;

    const removeLink = event.target.closest(REMOVE_LINK);
    if (removeLink && removeLink.dataset.wlConfirmed !== 'true') {
      const quantity = removeLink.closest('line-item-quantity');
      const prompt = quantity?.nextElementSibling;
      if (!prompt?.classList.contains('wl-remove-prompt')) return;
      event.preventDefault();
      event.stopImmediatePropagation();
      quantity.hidden = true;
      prompt.hidden = false;
      prompt.querySelector(YES_BUTTON)?.focus();
      return;
    }

    const yesButton = event.target.closest(YES_BUTTON);
    if (yesButton) {
      const prompt = yesButton.closest('.wl-remove-prompt');
      prompt.querySelector('[data-wl-remove-status]').hidden = true;

      if (!window.ooo?.wishlist?.functions?.isWishlistAccessible?.()) {
        event.preventDefault();
        event.stopImmediatePropagation();
        showError(prompt, prompt.dataset.wlLoginRequired);
        return;
      }

      // Clicking an already-saved item would remove it from the wishlist.
      if (yesButton.getAttribute('aria-checked') === 'true') {
        event.preventDefault();
        event.stopImmediatePropagation();
        removeFromCart(prompt);
        return;
      }

      const noButton = prompt.querySelector('[data-wl-remove-prompt="no"]');
      if (noButton) noButton.disabled = true;
      let finished = false;
      let timeout;
      const finish = () => {
        if (finished) return false;
        finished = true;
        observer.disconnect();
        document.removeEventListener('ooo-wishlist:product-added', onAdded);
        clearTimeout(timeout);
        return true;
      };
      const fail = () => {
        if (finish()) showError(prompt, prompt.dataset.wlSaveError);
      };
      const onAdded = event => {
        const item = event.detail?.product;
        const component = yesButton.closest('ooo-wl-wishlist-button');
        if (item?.handle !== component.getAttribute('handle')) return;
        if (item.variant_id != null && String(item.variant_id) !== component.getAttribute('variant-id')) return;
        if (finish()) removeFromCart(prompt);
      };
      const observer = new MutationObserver(() => {
        if (yesButton.getAttribute('aria-busy') !== 'false') return;
        // An unsuccessful request does not dispatch product-added.
        fail();
      });
      document.addEventListener('ooo-wishlist:product-added', onAdded);
      observer.observe(yesButton, { attributes: true, attributeFilter: ['aria-busy'] });
      timeout = setTimeout(fail, 10000);
      // Allow the Wishlist Power button to handle this click.
      return;
    }

    const noButton = event.target.closest(NO_BUTTON);
    if (noButton) {
      event.preventDefault();
      event.stopImmediatePropagation();
      removeFromCart(noButton.closest('.wl-remove-prompt'));
    }
  }, true);
})();

Load the new asset in layout/theme.liquid after the theme’s script:

<script type="module" src="{{ 'wishlist-cart-remove-prompt.js' | asset_url }}"></script>

4. Test the duplicate theme

  1. Click Remove in the drawer. The prompt appears and the item stays in the cart.
  2. Click Yes on an unsaved item. Confirm it appears in the wishlist before it leaves the cart.
  3. Click Yes on an item already saved. It should stay in the wishlist and leave the cart.
  4. Click No. The item leaves the cart and the wishlist does not change.
  5. Test a wishlist add failure or a store that requires login. The item must stay in the cart and show a message.
  6. Check that quantity controls and Remove on the full /cart page still work normally.

For another theme, inspect its drawer element, quantity/Remove wrapper, and Remove link, then change the selectors and the Liquid insertion point. If the prompt does not appear, compare those selectors with the rendered HTML in your browser. If Yes cannot save, verify the app embed is enabled and check the browser console. For the underlying component behavior, see <ooo-wl-wishlist-button>.