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

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

Leon09
Tourist
23 0 1

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! 🙏

Replies 6 (6)

thescriptflow
Shopify Partner
611 41 81

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.

- Need a Shopify Specialist? Chat on WhatsApp Or Email at info@thescriptflow.com

- Boost Your Sales with Affiliate Marketing - UpPromote: Affiliate & Referral


- If my solution was helpful, mark it as a solution and hit the like button! And Wait Don't forget to Buy me a Coffee

Leon09
Tourist
23 0 1

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! 🙏

oscprofessional
Shopify Partner
16366 2440 3188

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');
});

  4. Prevent flashing by placing the Notify button in HTML but hiding it by default.

Hire us | Pass Core Web Vital | B2B Wholesale Experts | Claim Your Free Website Review |
Connect with Us: WhatsApp | Skype: oscprofessionals-87 | Email: pallavi@oscprofessionals.com |
Custom Shopify SolutionsPrivate Apps, Theme Customization & SEO | Digital Marketing |
OSCP Apps: Discount Suite | Wholesale App | Bundle & Upsell | Shipping Discount | and more...
Leon09
Tourist
23 0 1

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! 🙏

Zel_Minimate
Shopify Partner
73 0 4

Hi @Leon09 ,

If you're trying to automatically replace the PayPal button with a "Notify Me" option when a product is sold out, you might find it easier to use a no-code solution rather than custom code — especially if that code didn’t work as expected.

Our app, Mini: Coming Soon | Waitlist, does exactly that you asked for.

  • It automatically hides purchase buttons (like PayPal or Add to Cart) for out-of-stock products.
  • Replaces them with a “Notify Me” form so customers can join a waitlist.
  • You’ll collect emails from interested shoppers and notify them when the product is back or available


Screenshot 2025-04-14 at 14.57.05.png

 


No code needed — it works with most themes out of the box, and setup takes just a few minutes.


Happy to help if you need assistance getting started!


Best,
Zel 

MINIMATE APPS - CUSTOMIZATION & SCARCITY MADE SIMPLE!
Mini Customization Fields: Effortlessly create and manage custom product fields for a personalized product options.
Mini: Coming Soon | Waitlist : Maximize revenue through waitlists and pre-orders.
Hey! Scarcity Low Stock Counter: Boost sales by displaying low stock message to create a sense of urgency.
Explore Our Apps for Free | 24/7 Dedicated Support for Shopify merchants

Sandy--STOQ
Shopify Partner
108 5 14

Hey @Leon09 👋🏼 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. 🙂

STOQ: Preorders & Back in stock alerts made easy for Shopify
Filemonk: Sell digital products & downloads in 3 quick steps

Founder & CEO, Artos Software