Liquid, JavaScript, themes, sales channels
I set up a 10% discount coupon for newsletter subscribers.
Now I am wondering if somebody could show me how I can modify this page: https://otaro-shop.com/account/subscribe?email=elg72723%40zzrgg.com&token=-4fl89huPoxEiHmCG4wVEC-alL...
It seems like this page is generated dynamically for each Subscriber of our Newsletter. I would like to add a nice button to activate a coupon (10% discount after he successfully susbscribed) and some basic HTML.
I know that I can add some text via the "Language" option (how already done) but HTML or adding a button is not possible with this adjustment...
Highly appreciate your help!
Best,
Adrian
Did you find a solution? I am also not able to finde the pages for email marketing (/account/subscribe etc.)
Did you find a solution to this?
I haven’t tried it out but these pages (although dynamically created and controlled by Shopify) use the page template. So you can use a conditional in liquid, test if the visitor is on the capcha page and then show a custom section or other code.
Sorry, I had to find the reference post. It is the theme.liquid file - not page.liquid.
{% if request.path == '/challenge' %}
{% render 'challenge' %}
{% else %}
{{ content_for_layout }}
{% endif %}
So in the theme.liquid file you can make a conditional for the request.path and then render a custom section.
However, in the case of the challenge page (the first step after the newsletter signup form has been submitted and captcha is enabled), the whole captcha validation might not be so easy. You'd need to do some research on the pitfalls and know exactly in which scenarios the challenge page is shown.
Yes, in theme.liquid just check what the request.path is and you can replace {{ content_for_layout }} with anything you like:
request.path
So I replaced
{{ content_for_layout }}
with
{% if request.path == '/account/subscribe' %}
{% render 'THIS IS A TEST' %}
{% else %}
{{ content_for_layout }}
{% endif %}
It replaced the content but with the following:
Liquid error: Could not find asset snippets/THIS IS A TEST.liquid
Do I need to create anothe file too?
Or do I just do it like this:
{% if request.path == '/account/subscribe' %}
<h1>This is a test - MY HTML HERE</h1>
{% else %}
{{ content_for_layout }}
{% endif %}
This is another way of doing it. You are free to use snippets, sections or "direct" code (like the HTML in your last example).
perfect I will try with snippets as this will be neater.
My only concern is if there are any other pages that are build from this path.
for example the content I see is account/subscibe?email=.... etc
but what if different content is genrated if there is a different query string used that I am not yet aware of.. I guess this will have to be trial and eror and LOTs of testing to make sure I havent replaced other content with a generic peice of content. does taht make sense?
Great!
Yes, as I mentioned before You'd need to do some research on the pitfalls and know exactly in which scenarios the page is shown.
Like you say, trial and error, testing, researching will map the scenarios, and you can then apply the appropriate functionality to each.
the plu side the unsubscribe has its own page so it doesnt affect that one 🙂 that one is account/unsubscribe
Thanks though, works a treat
Hello,
I'm facing with the same Issue what did you. I was wondering, did you manage to replace a Template as you wanted?
I don't have much experience in the HTML, but I can do some basics, can you, please help me with the code, what need to be place in the content_for_layout to have us you have now in the email. I will appreciate your help highly.
|
|
|
|
Create a snippet file with your HTML
then follow the instructions on what to do with the theme.liquid file a few posts back. Replace THIS IS A TEST with the name of the snippet file (without the .liquid)
Hello,
Thank you for this helpful discussion. I am able to create my subscription page as instructed herein, however, I would like to display different languages when needed. My original store language is German, however, I also have an "English" option.
Could you help me with that?
Kind regards,
Ayse
Hello again,
How do you get the correct unsubscription link x in your newly created snippet for the line:
<a href = "x">
Could you help me with that?
Kind regards,
Ayse
Is there a problem with the link then? Or is it not displayed?
I just wanted to put a unsubscribe link, but I could not find what is the correct http (source) for it.
Could you help me with that?
Kind regards,
Ayse
I will look into it. I have just realised that there is an error In my link actually. If I haven’t got back to you in a week or so remind me!
Thanks @Tarik-Fanarik I will give this a go. I never got around to finding a solution for this.
Hi! I have a custom confirmation page and I am trying to add at the bottom the unsubscribe link but I haven't been able to do it, do you know how to do it?
At the end i did it like this:
Create a _account-subscribe.liquid and a _account-unsubscribe.liquid snippet.
From theme.liquid you need to pass the unsubscribe_url variable to the _account-subscribe.liquid snippet. Like in this code example:
{% if request.path == '/account/subscribe' %}
{%- assign unsubscribe_url = content_for_layout | split: 'href="' | last | split: '">' | first -%}
{% render '_account-subscribe', unsubscribe_url: unsubscribe_url %}
{% elsif request.path == '/account/unsubscribe' %}
{% render '_account-unsubscribe' %}
{% else %}
{{ content_for_layout }}
{% endif %}
Inside the _account-subscribe.liquid snippet then you can use it like:
<a href= {{ unsubscribe_url }} >Unsubscribe from this shit</a>
Of course you can name snippets and variables as you like. However if you copy/paste like in the example it will work right away.
Good luck! 🙂
Hi Phil,
After coming across this same issue on the account/subscribe page, I found your solution on this forum when investigating solutions. Really helpful. Solved my issue on the desktop and tablet version of my site.
HOWEVER, this does not work on the mobile version. Just a blank screen comes up.
Is there some more code I can add to account for mobile visitors?
Thank you 🙂
Yes, {{ render }} refers to snippets.
Thanks a lot tokant. It was very helpful.
User | RANK |
---|---|
33 | |
26 | |
19 | |
9 | |
9 |
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023