Hello, I want some pages that customer can enter only after he has an account and is logged in.
And if he logged in, he can automatically enter the pages.
In short, the pages are linked to the account, if the customer is registered, he can enter in, and if he is not registered, he can not enter
Hi @Yousif77
To support you better, I suggest you provide us with information about the theme you are using.
Also, we would like to offer the simplest solution is that hide the content of that Page for non-logged customers and replace that content with other sections. You can follow these steps:
- Step 1: Go to Current Theme => Edit code
- Step 2: Select the theme.liquid file and edit it according to the following steps.
- Step 3: You search for the section {{ content_for_layout }} (for the mian-content section), {% section ‘announcement-bar’ %} and {% section ‘header’ %} (these two contain headings) and finally is {% section ‘footer’ %}.
Here is an example of the Dawn theme:
- Step 4: After finding those snippets, you can add this code to wrap those layouts. Specifically: You add this line of code to the sections you want to hide:
{% CONDITION %}
SECTION_TO_HIDE
{% else %}
SECTION_TO_REPLACE
{% endif %}
For example. If you don’t want non-logged customers accessing the product page, and you want to hide the main-content, replace it with the login section page. You can add the following code:
{% customer and template != "product" %}
{{content_for_layout }}
{% else %}
{% section 'main-login' %}
{% endif %}
{% endif %}
Or if you want to report that “page not found,” you can write this code like this (theme Dawn):
{% if customer or template != "product" %}
{% assign condition = true %}
{% else %}
{% assign condition = false %}
{% endif %}
{% if condition or template contains 'login'%}
{{content_for_layout }}
{% else %}
{% section 'main-404' %}
{% endif %}
Note that SECTION_TO_REPLACE may vary depending on the theme. Please check in the Section folder to check the existence and name of those sections.
I hope the above will be helpful to you.
Besides, if you’re running B2B/ Wholesale Solution, we suggest you try the B2B Login/Lock and Hide Price app which has all the features you are looking for and much more.