Hide Buy Button if not logged in

Open to all! Ask other shopowners for help.
Post Reply
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Hide Buy Button if not logged in

Post by Portman »

Hi Everyone,

Sorry, its been a few years since I have played around with my store and have forgotten most of what I had learnt...

I feel like this should be an easy one that people have done multiple times before, but I just cant get it...

I want to hide the Buy button if a customer is not logged in.

I have added;

Code: Select all

if ( isset($_SESSION['customer_id']) ) {
to the top of tpl_cm_pi_buy_button.php but this is generates an unexpected if statement error.

any help would be appreciated


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Hide Buy Button if not logged in

Post by burt »

Assuming you are using override template;

1. Undo any changes you have made, and drop a COPY of
/includes/modules/content/product_info/templates/tpl_cm_pi_buy_button.php
to
/templates/override/includes/modules/content/product_info/tpl_cm_pi_buy_button.php

2. In that new template file;

Code: Select all

<?php
if (isset($_SESSION['customer_id'])) {
  ?>
 The content of the file, unchanged.
<?php
}
?>
Sounds like you (a) are not using the overridable features we've introduced and (b) forgot about <?php tags
I am not here to build for you.
I am here to build with you. Let's help each other.
User avatar
Portman
Contributor
Posts: 158
Joined: Mon Mar 08, 2021 1:04 am
Phoenix Version: v1.0.8.20
Has thanked: 29 times
Been thanked: 4 times

Re: Hide Buy Button if not logged in

Post by Portman »

I feel like an idiot, thanks
dodgyhuw
Member
Posts: 14
Joined: Thu Jul 13, 2023 3:43 pm
Phoenix Version:
Has thanked: 11 times

Re: Hide Buy Button if not logged in

Post by dodgyhuw »

Nice touch! In what other scenario may this be used to make our stores better?


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