This article only applies to the new designer. Not sure which designer you have? Check here.

By default, when a customer logs out of their account, they'll be taken to the main page of your shop. If you want them to be sent to a different location, you can use the Code Editor to change the log out link.

As when making other code changes, be sure to first make a copy of your theme to work with. The copy can be published once reviewed and ensured is working as expected.

1. Find the log out link in the Code Editor

The log out link in new designer templates is found under /components/global/header/component.html.

What you're looking for should be a subnav along the lines of:

{% for subitem in item.children %}
<li><a href="{{ subitem.url }}" class="nav-link">{{ subitem.title | safe }}</a></li>
{% endfor %}

2. Update the link code

The links in the new designer are created dynamically based on the links you have created or modified in the visual designer, so we need to override those automatically generated links. We do that by saying if the link URL points to '/customer/logout', use this link instead, otherwise use the default.

The updated code should look like this:

{% for subitem in item.children %}
{% if subitem.url == '/customer/logout' %}
<li><a href="https://www.google.com" class="nav-link" onclick="$.ajax({url: '/customer/logout',type: 'GET',success: function(response){;}});">{{ subitem.title | safe }}</a></li>
{% else %}
<li><a href="{{ subitem.url }}" class="nav-link">{{ subitem.title | safe }}</a></li>
{% endif %}
{% endfor %}

Be careful to only replace the code within the subnav. Change "https://www.google.com/" to be wherever you want customers to end up.

3. Test it!

It's easy to make a seemingly innoculous typo and end up with a broken log out link. Log in to your store (you can use your merchant account credentials as if you're a customer) and test each log out link, making sure that it does in fact log you out, and takes you where you wanted.

If you've done the above steps and can't find any typos, but it's not working properly, email [email protected] and we can take a look at what's going on.