Newsletter Language for Already Subscribed Users

onyx_au
Explorer
57 1 17

Hi,

 

In the theme language settings, it seems there's only a post-submit message if someone has NOT subscribed to our mailing list.


But when a subscribed e-mail tries to sign up again, the page refreshes and does nothing and does not give an error message like "You have already subscribed!"

How can I add a "You have already subscribed!" post-message if someone tries to re-subscribe?

Replies 3 (3)
SheetalZadfiya
Explorer
70 15 19

Hi @onyx_au

 

Newsletter Language for Already Subscribed users you need to add following code:

 

Add following script on this file: SALES CHANNELS > Online Store > Themes > Actions > Edit code > Assets > global.js

var live_url = window.location.href;
var result = live_url.includes('form_type=customer');
var input_val = document.querySelector('#NewsletterForm--footer').value.length;
if(result && input_val != 0){
    const add_ele = document.createElement("h3");
    add_ele.innerText = "You have already subscribed!";
    document.querySelector('.newsletter-form__field-wrapper').appendChild(add_ele);
    add_ele.classList.add('newsletter_already_subscribe','newsletter-form__message','form__message');
}

 

Add following CSS code on this file: SALES CHANNELS > Online Store > Themes > Actions > Edit code > Assets > component-newsletter.css

.newsletter_already_subscribe{
  color: red;
}

 

How it will looks like after adding above code in your Shopify Store:

image-20220524-070729.png

Thank you.

If our answer is helpful then please feel free to Like and Accept it as solution!
Hire our Shopify Developers for all your small & big needs:
New Store Development | Custom Theme Development | Site Speed Optimization
Email: hello@mintyourstore.com | Instagram: @mintyourstore
atlanticmorning
Tourist
4 0 0

Worked perfectly for me!

avaskye
Excursionist
34 0 7

Hi @SheetalZadfiya ! Would you happen to have an updated code for the Dawn theme? I tried using the code above to enable the "You've already subscribed!" message, but it doesn't appear to work. Thank you so much in advance!