How to hide the "Pay with PayPal" button and show a "Notify Me" button when a product is sold out?

Topic summary

A Shopify store owner seeks to automatically replace the “Pay with PayPal” button with a “Notify Me” button when products are out of stock on a third-party theme.

Key Requirements:

  • Reliable functionality across all page loads and variant changes
  • Prevent accidental triggering of out-of-stock actions
  • Eliminate button flashing during variant switches (currently “Notify Me” briefly appears even when items are in stock)
  • Display a popup when “Notify Me” is clicked

Proposed Solutions:

Code-based approach: Use conditional logic (if/else) to toggle button visibility based on variant.available status. A JavaScript snippet was provided using variant:change event listeners to update buttons instantly and prevent flashing by pre-hiding the “Notify Me” button in HTML.

App solution: STOQ back-in-stock alerts app was recommended as a ready-made alternative, offering instant loading, reliable variant tracking, customizable popup options, and support to prevent PayPal button flashing.

Current Status: The original poster attempted implementing the custom code unsuccessfully and requested direct implementation assistance. The discussion remains open with no confirmed resolution.

Summarized with AI on October 29. AI used: claude-sonnet-4-5-20250929.

Hey everyone,

I’m working on a Shopify site using a third-party theme, and I’m trying to automatically replace the “Pay with PayPal” button with a “Notify Me” button whenever a product or variant is out of stock. Here’s what I need it to do:

  • Work reliably on every page load and variant change

  • Ensure that clicking the “Notify Me” button doesn’t trigger the out-of-stock functionality by mistake

  • Improve response time: currently, on variant switch, the “Notify Me” button sometimes flashes briefly even when the product is in stock and PayPal buttons load afterward

My main goal is to keep the same functionality, but make the button update faster and more smoothly.

Also, when someone clicks “Notify Me”, I want a popup to appear. If anyone has a good approach for this, I’d be happy to share the code I’ve been working with!

Appreciate any ideas or help—thanks so much! :folded_hands:

This need to do a custom coding in order to achieve this.

Mainly there will use if, else condition. Mean if product sold out then the “Pay with Paypal” will display none.

This need to do coding based of your theme.

Hi @Leon09 ,

To replace the PayPal button with a “Notify Me” button when a variant is out of stock:

  1. Hide PayPal and show “Notify Me” based on variant.available status.

  2. Listen for variant:change to update buttons instantly when switching variants.

  3. Use this code:

document.addEventListener('variant:change', function (e) {
  const variant = e.detail.variant;
  document.querySelector('.shopify-payment-button').style.display = variant.available ? 'block' : 'none';
  document.getElementById('notify-me-btn').style.display = variant.available ? 'none' : 'block';
});

document.getElementById('notify-me-btn').addEventListener('click', function () {
  // Trigger your popup here
  alert('Notify me popup');
});
  1. Prevent flashing by placing the Notify button in HTML but hiding it by default.

Hi @oscprofessional ,

Thanks for your suggestion! I tried to implement the code myself, but unfortunately I can’t get it to work.

Would you possibly help me and implement the code directly for me? I would be very grateful if you could do this for me.

Many thanks in advance! :folded_hands:

Hi @TheScriptFlow ,

Thanks for your suggestion! I tried to implement the code myself, but unfortunately I can’t get it to work.

Would you possibly help me and implement the code directly for me? I would be very grateful if you could do this for me.

Many thanks in advance! :folded_hands:

Hey @Leon09 :waving_hand:t3: We got you covered on STOQ - our app for back in stock alerts & preorders. Worked with tens of thousands of merchants over the last 3 years on exactly the type of flow you’re looking for.

  1. STOQ tracks variant changes and works extremely reliably on all page loads.
  2. Clicking our “Notify me” button won’t trigger any add-to-cart flow.
  3. Our button loads pretty much instantly, and we can have it so that your Paypal button never flashes/appears through some additional custom code.
  4. With STOQ, you can set it up so customers see a popup when they click “Notify me” or you can show the popup directly on the page to improve conversion to signup.

We have a generous free plan and 24*7 support. Let me know if you have any questions or if there’s anything we can do to get you set up. :slightly_smiling_face: