All things Shopify and commerce
We’re looking to add a "You've already subscribed!" message for users who have already signed up for our newsletter (both through our pop-up newsletter form and the sign-up form at the bottom of our homepage). This is for a Symmetry theme, and we’re happy to compensate for the work. If any developer can assist with this, we would greatly appreciate it—thank you in advance!
Hey @avaskye ,
To implement a "You've already subscribed!" message in the Symmetry theme, the process involves detecting whether a user is already subscribed and then displaying the appropriate message. Here’s a general outline of how this can be done:
1. Front-End Message Display:
Add a dynamic message display using Javascript:
document.getElementById('newsletter-form').addEventListener('submit', function(e) {
e.preventDefault();
const email = document.querySelector('#email-input').value;
fetch('/check-subscription', { method: 'POST', body: JSON.stringify({ email }) })
.then(response => response.json())
.then(data => {
if (data.alreadySubscribed) {
document.querySelector('#newsletter-message').textContent = "You've already subscribed!";
} else {
document.querySelector('#newsletter-message').textContent = "Thank you for subscribing!";
}
});
});
Add CSS to style the message so that it fits your theme's design
#newsletter-message {
color: #d9534f;
font-size: 14px;
margin-top: 10px;
}
If you’d like, I can provide the exact Liquid and JavaScript code based on how your current forms are structured. Let me know if you'd like further assistance with implementation, and we can work out the details!
Thanks
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024