No Guests : Customer Login required like Admin Login
Posted: Mon Aug 09, 2021 11:30 pm
by Nigel
No Guests : Customer Login required like Admin Login
I would like the customer landing page to be a login like the admin.
I have spent the past few hours trying to find info on the forum and also looking through the files.
Can a customer go straight to the login.php like an Admin does and all areas of the cart require a successful login ?
Customers are current active customers whose online accounts would be initially created for them and their login details issued to them. This is normal practise in my industry.
I'm looking to create an ordering portal for trade customers who we currently contact via telesales.
Thanks for any advice / input.
Nigel
Re: No Guests : Customer Login required like Admin Login
class hook_shop_siteWide_loginRequired {
public function listen_siteWideStart() {
$page = basename(Request::get_page());
if (('create_account.php' !== $page) && !Text::is_prefixed_by($page, 'log')) {
Login::require();
}
}
}
Re: No Guests : Customer Login required like Admin Login
Posted: Tue Aug 10, 2021 8:24 am
by zipurman
In case you need help creating the hook above:
Re: No Guests : Customer Login required like Admin Login
Posted: Tue Aug 10, 2021 9:32 am
by Nigel
My site is set to override on the templates section.
does the hook still go into default or overrides ?
Am I right in thinking a copy of the htaccess in the templates/default should also exist in templates/override ?
Re: No Guests : Customer Login required like Admin Login
Posted: Tue Aug 10, 2021 10:56 am
by ecartz
Nigel wrote: ↑Tue Aug 10, 2021 9:32 am
My site is set to override on the templates section.
does the hook still go into default or overrides ?
The only time it would matter would be if there were two hooks, one in each place. Then override should defeat default. But if there's only one, then either place should work.
Nigel wrote: ↑Tue Aug 10, 2021 9:32 am
Am I right in thinking a copy of the htaccess in the templates/default should also exist in templates/override ?
If only there were a reference implementation, then you could just look there:
Nigel wrote: ↑Tue Aug 10, 2021 9:32 am
My site is set to override on the templates section.
does the hook still go into default or overrides ?
The only time it would matter would be if there were two hooks, one in each place. Then override should defeat default. But if there's only one, then either place should work.
Nigel wrote: ↑Tue Aug 10, 2021 9:32 am
Am I right in thinking a copy of the htaccess in the templates/default should also exist in templates/override ?
If only there were a reference implementation, then you could just look there:
Core provides three files inside the override directory tree, and all three should exist in your installation.
My version didn't have the htaccess in there.
Is it recommended to use the github as a reference, if that's what you're implying ?
Re: No Guests : Customer Login required like Admin Login
Posted: Tue Aug 10, 2021 11:39 am
by ecartz
Nigel wrote: ↑Tue Aug 10, 2021 11:09 am
My version didn't have the htaccess in there.
They should have been added in the 1.0.7.13 update, which is what created the override folder.
Nigel wrote: ↑Tue Aug 10, 2021 11:09 am
Is it recommended to use the github as a reference, if that's what you're implying ?
Yes. In a normal install, the only files that should change from the GitHub versions are the configure.php files. All other modified files should be in one of the override places:
admin/includes/classes/override
includes/system/override
templates/override
It is possible to create an alternative to the override template, which could be named almost anything other than default or override. New files (that don't conflict with core files) could go anywhere.
Note that English language files used to be modified in place but now should go under templates/override/includes/languages in catalog. Hopefully you don't have any reason to modify the language files under admin or install. This is covered at How to Change Text
Modules don't really work well with that system, so should generally be copied and renamed. The ot_shipping module is an exception, as it won't override all the behavior if renamed. One of these days, I should probably fix that.
Re: No Guests : Customer Login required like Admin Login
<?php
class hook_shop_siteWide_loginRequired() {
public function listen_siteWideStart() {
$page = basename(Request::get_page());
if (('create_account.php' !== $page) && !Text::is_prefixed_by($page, 'log')) {
Login::require();
}
}
}
I placed it in templates/default/includes/hooks/shop/siteWide with no success. Just error 500.
I then tried by adding hooks/shop/siteWide to the override section as that's how it's set in myStore. Still no joy.
I've watched Zipurman's video many times and still can't see what I'm missing.
Re: No Guests : Customer Login required like Admin Login
Posted: Tue Aug 10, 2021 11:20 pm
by zipurman
Nigel wrote: ↑Tue Aug 10, 2021 10:48 pm
I've watched Zipurman's video many times and still can't see what I'm missing.
What version of Phoenix are you running?
What version of PHP are you using?
What does the error log say, as with a 500 error you should have some log entries?
Re: No Guests : Customer Login required like Admin Login
Posted: Tue Aug 10, 2021 11:34 pm
by Nigel
Installed Version: CE Phoenix v1.0.8.5
PHP Version 7.3.27 (Zend 3.3.27)
[Tue Aug 10 23:52:38 2021] [error] [client xxx.xxx.xxx.133:0] PHP Parse error: syntax error, unexpected '(', expecting '{' in /home/sites/blahblah.com/public_html/top/templates/override/includes/hooks/shop/siteWide/loginRequired.php on line 3