Shopify themes, liquid, logos, and UX
I need to put a link on some of my customers' account pages so that they can access and click the link after signing in. I want to avoid an app if possible. I figured out as a workaround that I can add the link as a "new address" and then make that "address" the default so it will show on my customer's page. However, the customer is still going to have to copy the link and paste it into a browser. Shopify won't let me enter the link as an anchor tag -- it says no HTML allowed. Any suggestions? I asked a guru how to code in a field to the account page for this purpose and was told it is a "major" coding project.
Solved! Go to the solution
This is an accepted solution.
So yeah this is possible too. So let's just say you want to link them to google for arguments sake. Tag them like "link--https://www.google.com". Then in the customers/account.liquid page you can loop through them, check if the tag contains 'link', split the tag by the double dash, and put the last part of the tag in an anchor:
{% assign url = false %}
{% for tag in customer.tags %}
{% if tag contains 'link' %}
{% assign url = tag | split: '--' | last %}
{% endif %}
{% endfor %}
{% if url %}
<a href="{{ url }}">Click here to go to google</a>
{% endif %}
You may want to use a more unique character to split by in case there's any double dashes in any of the urls you provide. Maybe like dollar signs or something.
What are you linking to? Is this conditional in any way? Like only some customers should see it? There's no reason you can't just put a link in your customers/account.liquid file in your templates folder.
Thanks for replying! Yes, it's conditional. It can't show up on every customer's account page. Only on those that I have manually added it to. I'm linking to an outside location.
Tag the customers that you want to see the link, use something like "outside-link" then in the customers/account.liquid file you can say:
{% if customer.tags contains "outside-link" %}
<a href="https://www.google.com">Click here to go to google</a>
{% endif %}
Hmmmm, getting close.. thanks for your patience.
The link is UNIQUE to each customer. I was trying to simplify my question but I failed to give you enough information. I will be selling digital content that is stored outside of Shopify (on Dropbox), and each customer's content is different and thus they need a unique link. Maybe I can tag each customer with their unique link being the tag, then in the customers/account.liquid file, check for the tag and post it on the page (as a link) if it exists. If I can figure out how to do all that lol🙂
This is an accepted solution.
So yeah this is possible too. So let's just say you want to link them to google for arguments sake. Tag them like "link--https://www.google.com". Then in the customers/account.liquid page you can loop through them, check if the tag contains 'link', split the tag by the double dash, and put the last part of the tag in an anchor:
{% assign url = false %}
{% for tag in customer.tags %}
{% if tag contains 'link' %}
{% assign url = tag | split: '--' | last %}
{% endif %}
{% endfor %}
{% if url %}
<a href="{{ url }}">Click here to go to google</a>
{% endif %}
You may want to use a more unique character to split by in case there's any double dashes in any of the urls you provide. Maybe like dollar signs or something.
This is great! I will try it and come back and tag your answer as a solution when I get it working. I like this idea!! Thanks for your prompt replies.
No problem, as you can see this was a "major" coding project.
LOL I should have come to the forums at the start! Great first experience so far, thank you
Hi.. I had similar issue. could you help if i want to add a small description and also clickable link on account page?
So the customer can view this when they are logged in into their account. to access marketing material
thank you so much!
Hey @andra0412 , so you can definitely do this. Go to Settings > Custom Data > Customers to set up a Customer metafield:
Click Add Definition when prompted and you'll be brought to add customer metafield definition. You'll need to name the metafield so call it something like Description with link, add a description for it if you'd like, and then click to add the type of metafield and select Rich text, then click save.
Then go to the customer in the admin you want to add the description to and you'll see the new metafield:
Click into it and you can add your description, the rich text editor has some basic editing options like bold, italics, list, and you can add a link in there as well, I'm just gonna link to google
Then click save in the top right corner of the screen, should be in the top black bar in the shopify admin
Then in your theme code you're going to want to go into customers/account.liquid in your Templates folder, I'm using Dawn theme. I just want to output it directly under the logout button or whatever:
In the code you'll want to check if the metafield isn't blank, and then output it:
{% if customer.metafields.custom.description_with_link != blank %}
{{ customer.metafields.custom.description_with_link | metafield_tag }}
{% endif %}
Then you'll see it in the account page. I'm hovering the link and you can see in the bottom left that it's linking to google.com:
And that's that
thank you so much it worked! but one thing.. i would like this to be in all our customers account.
and the way you told me i need to add this one by one in customer account. is there any other way i dont need to apply it one by one?
Oh sorry I misunderstood, I thought it would need to be specific to customer. In that case, most of what I told you was unnecessary lol. So wherever you placed the code in customers/account.liquid -- you'll just need to put some plain HTML for what you want. So instead of the metafield code with the check to see if the metafield was blank that I provided above, just do something like
<p>Here's some text you want to output on every customer account page. <a href="https://google.com">Here's a link for your marketing information.</a></p>
Just replace the text with whatever you want and replaced the "href" attribute with the link that you need to provide everybody.
perfect! thanks so much
Just came across this and it worked perfectly. Only question is, if I wanted to also add the link to the drop down list when they click on their "My account" link in the top menu, how where would I add the if statement?
Nice solutions you posted here, congratulations.
I am trying to implement it but it seems that the themes have been updated since then and I can't make it work.
Right now in the user account menu i have the link for back to shop and another for orders. I want to add another element in this menu that display for every user. This element is linked to a url that is different for every customer. If there is no url saved for a specific customer it will display a text message.
Can you please help me with a solution for what I am trying to accomplish? Thanks
Is there a way to add a link when a customer.tags is not present? The opposite of the example you have given? Thanks.
I Want To Redirect My Checkout Button To My Custom Link
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