Hide Buy Button if not logged in

Ask the community for help with CE Phoenix Cart.
Post Reply
User avatar
Portman
VIP Member
VIP Member
Posts: 130
Joined: Mon Mar 08, 2021 1:04 am
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
burt
Lead Developer
Lead Developer
Posts: 2798
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 52 times
Been thanked: 159 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
Did this post help you? Please Beer me, TY.
Current Beer Fund: £1.11

#wearephoenix
#wearecommunity
User avatar
Portman
VIP Member
VIP Member
Posts: 130
Joined: Mon Mar 08, 2021 1:04 am
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
Posts: 14
Joined: Thu Jul 13, 2023 3:43 pm
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?
Post Reply