No Guests : Customer Login required like Admin Login

Open to all! Ask other shopowners for help.
Nigel
Contributor
Posts: 114
Joined: Mon Jan 11, 2021 1:39 am
Phoenix Version:
Has thanked: 29 times
Been thanked: 8 times

Re: No Guests : Customer Login required like Admin Login

Post by Nigel »

Comparing Zipurman's video and ecartz' code, the error on line 3 seems to be the inclusion of open and close parenthesise at the end of the class declaration.
Removing them allows it to work straight away.

Code: Select all

class hook_shop_siteWide_loginRequired {
not

Code: Select all

class hook_shop_siteWide_loginRequired() {
Is this the correct solution or should I do something else ?


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: No Guests : Customer Login required like Admin Login

Post by zipurman »

That is correct. Class syntax should not include (). Good catch.
zipurman
-----------
Nigel
Contributor
Posts: 114
Joined: Mon Jan 11, 2021 1:39 am
Phoenix Version:
Has thanked: 29 times
Been thanked: 8 times

Re: No Guests : Customer Login required like Admin Login

Post by Nigel »

I've been away from the software for a while but started again this weekend.
I lost my mother to a severe stroke and it takes your mind to a different place and changes your perspective of what's important and your priorities.

The login required seems to work well but the What's new side bar shows the price of the item when not logged in.
Can anyone suggest what I should do please ?
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: No Guests : Customer Login required like Admin Login

Post by zipurman »

Nigel wrote: Mon Aug 30, 2021 8:42 pm I've been away from the software for a while but started again this weekend.
I lost my mother to a severe stroke and it takes your mind to a different place and changes your perspective of what's important and your priorities.

The login required seems to work well but the What's new side bar shows the price of the item when not logged in.
Can anyone suggest what I should do please ?
So sorry to hear about your mother. My condolences.

You could edit the includes/modules/boxes/bm_whats_new.php

You could change add the following to the function execute() {

Code: Select all

function execute() {

  if (($GLOBALS['customer'] ?? null) instanceof customer) {

** leave all the code in here ***

   }
  
}
zipurman
-----------
Nigel
Contributor
Posts: 114
Joined: Mon Jan 11, 2021 1:39 am
Phoenix Version:
Has thanked: 29 times
Been thanked: 8 times

Re: No Guests : Customer Login required like Admin Login

Post by Nigel »

zipurman wrote: Mon Aug 30, 2021 10:56 pm
Nigel wrote: Mon Aug 30, 2021 8:42 pm I've been away from the software for a while but started again this weekend.
I lost my mother to a severe stroke and it takes your mind to a different place and changes your perspective of what's important and your priorities.

The login required seems to work well but the What's new side bar shows the price of the item when not logged in.
Can anyone suggest what I should do please ?
So sorry to hear about your mother. My condolences.

You could edit the includes/modules/boxes/bm_whats_new.php

You could change add the following to the function execute() {

Code: Select all

function execute() {

  if (($GLOBALS['customer'] ?? null) instanceof customer) {

** leave all the code in here ***

   }
  
}
Sorry for the delay in response.

Thanks re. my mum.

Should this be added as a user template by creating modules/boxes/bm... ?
Furthermore, is your if statement surrounding everything in the execute function ?
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: No Guests : Customer Login required like Admin Login

Post by zipurman »

Yes, you would EDIT the file includes/modules/boxes/bm_whats_new.php

Then wrap the entire execute logic (everything inside the function) with the if statement.
zipurman
-----------
Nigel
Contributor
Posts: 114
Joined: Mon Jan 11, 2021 1:39 am
Phoenix Version:
Has thanked: 29 times
Been thanked: 8 times

Re: No Guests : Customer Login required like Admin Login

Post by Nigel »

zipurman wrote: Mon Oct 04, 2021 10:49 pm Yes, you would EDIT the file includes/modules/boxes/bm_whats_new.php

Then wrap the entire execute logic (everything inside the function) with the if statement.
Thanks.
Second attempt worked fine.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply