Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
Forum Search
Google Site Search
Author « Topic »  

Marshall
Ecommerce Template Guru

USA
1957 Posts

Posted - 08/13/2025 :  03:44:05  
PHP v 7.7.9

I need a script, PHP or JavaScript, that will change an announcement depending on login level, e.g.
Login Level 0 this text
Login Level 1 different text

I'm a little rusty on this so any help would be appreciated.

Thanks in advance.

Marshall
CENLYT Productions - ms designs
Affordable Web Design
Custom Ecommerce Designs
Responsive Websites
Cenlyt.com

dbdave
ECT Moderator

USA
10578 Posts

Posted - 08/13/2025 :  08:43:35  
Have you tried AI?
I asked chat gpt the following prompt - for ecommerce templates version php 7.7.9 I would like some php code to create an announcement different for login level 1 and login level 0


It gave me all of this

Got it — you basically want a PHP snippet that will display one announcement if the user is logged in as level 1, and a different announcement if the user is logged in as level 0 (probably guest or basic account).

Since you didn’t mention the exact ecommerce template platform, I’ll give you a version-agnostic PHP 7.x-compatible example that you can adapt.
Example PHP Code

<?php
// Example: $login_level could come from your session, database, or auth system
// For example, if your system stores login level in $_SESSION:
session_start();

// This is just for example; replace with however your ecommerce template sets it
// $_SESSION['login_level'] = 1; // Logged-in level 1
// $_SESSION['login_level'] = 0; // Guest or level 0

$login_level = isset($_SESSION['login_level']) ? (int)$_SESSION['login_level'] : 0;

// Output different announcement based on login level
if ($login_level === 1) {
echo '<div class="announcement level1">
<p>#127881; Welcome back, valued member! Enjoy your exclusive 10% discount today!</p>
</div>';
} elseif ($login_level === 0) {
echo '<div class="announcement level0">
<p>#128075; Welcome! Sign up today to unlock member-only discounts.</p>
</div>';
} else {
// Optional: handle other levels if they exist
echo '<div class="announcement">
<p>#128226; Welcome to our store! Check out our latest deals.</p>
</div>';
}
?>

Notes for Integration

Where to place it: Most ecommerce templates have a header.php, index.php, or common/announcement.php file you can add this to.

Styling: Add CSS for .announcement.level1 and .announcement.level0 to make them visually distinct.

Data source: If your ecommerce system has its own $user object or $auth class, you can replace $login_level with the actual variable it uses.
Example:

$login_level = $user->login_level ?? 0;

If you tell me which ecommerce template you’re running (e.g., OpenCart, osCommerce, Zen Cart, etc.), I can adapt this so it pulls the login level directly from its built-in user session variables instead of the generic $login_level placeholder.

Do you want me to make this ready-to-paste for your exact ecommerce system?
You said:
Ecommerce Templates is the platform
ChatGPT said:

Perfect — Ecommerce Templates (ECT) actually stores the login level in a session variable named $_SESSION['clientLoginLevel'].

That means you can directly check that variable to display your two different announcements.

Here’s a ready-to-use snippet for PHP 7.7.9 on ECT:


<?php
session_start();

// ECT stores the login level in $_SESSION['clientLoginLevel']
// 0 = not logged in / guest
// 1 = basic logged-in user
// higher numbers = other customer groups

$login_level = isset($_SESSION['clientLoginLevel']) ? (int)$_SESSION['clientLoginLevel'] : 0;

if ($login_level === 1) {
echo '<div class="announcement level1">
<p>#127881; Welcome back, member! Your exclusive deals are waiting.</p>
</div>';
} elseif ($login_level === 0) {
echo '<div class="announcement level0">
<p>#128075; Welcome! <a href="login.php">Log in</a> or <a href="register.php">create an account</a> for special offers.</p>
</div>';
}
?>

dbdave
ECT Moderator

USA
10578 Posts

Posted - 08/13/2025 :  08:45:46  
Basically, I think adding this to includes would work

if ($login_level === 1) {
echo '<div class="announcement level1">
<p>#127881; Welcome back, member! Your exclusive deals are waiting.</p>
</div>';
} elseif ($login_level === 0) {
echo '<div class="announcement level0">
<p>#128075; Welcome! <a href="login.php">Log in</a> or <a href="register.php">create an account</a> for special offers.</p>
</div>';
}

David

Marshall
Ecommerce Template Guru

USA
1957 Posts

Posted - 08/13/2025 :  12:32:37  
Thanks David. This is what worked inserted into the cart.php page.

<?php
$login_level = isset($_SESSION['clientLoginLevel']) ? (int)$_SESSION['clientLoginLevel'] : 0;
if ($login_level === 1) {
echo '<p><em>Free shipping on orders of $250.00 or more limited to United States deliveries only.</em></p>';
} elseif ($login_level === 0) {
echo '<p><em>Free shipping on orders of $300.00 or more limited to United States deliveries only.</em></p>';
}
?>


Marshall
CENLYT Productions - ms designs
Affordable Web Design
Custom Ecommerce Designs
Responsive Websites
Cenlyt.com

dbdave
ECT Moderator

USA
10578 Posts

Posted - 08/13/2025 :  12:47:43  
Well it was actually close.
I forgot to mention, yes, you would need the link $login_level = isset($_SESSION['clientLoginLevel']) ? (int)$_SESSION['clientLoginLevel'] : 0; as well.
David
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.02 seconds. Snitz Forums 2000