Forums / Templates, Stylesheets, Page Layout / Call username and cart total in template

Call username and cart total in template

Locked

Started by bsmithtts on 24 Apr 2008, 1:42 AM · Views: 1,121

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
24 Apr 2008, 1:42 AM
#1
bsmithtts avatar

bsmithtts

New Zenner

Join Date:
Apr 2008
Location:
Arkansas
Posts:
6
Plugin Contributions:
0

Call username and cart total in template

Hello.

I have been working in Zen-Cart for about 2 years now. I design templates for our web design clients. Usually whenever I have an issue I can find a solution by searching the forums or using google to search these forums. However, tonight... I am at a small loss.

I might not be searching for the correct terms. If anyone can point me to the files to look into or provide me with the code I would appreciate it.

Here are the things I need to do:

  1. Call the user's username/nickname in the template (I already have a session switch in place to check to see if they are logged in or not)
  2. Call the total dollar amount that is currently in their cart. Even if it is zero.

I look forward to your replies.
Thanks!

  • Brian
  • Brian Smith
    "Worry is a misuse of imagination" - Dan Zadra
24 Apr 2008, 6:36 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Call username and cart total in template

I have been working in Zen-Cart for about 2 years now
If anyone can point me to the files to look into or provide me with the code I would appreciate it.
Hopefully you know that we might need to know where you want this displayed as the files required change depending on where

Zen-Venom Get Bitten

24 Apr 2008, 12:58 PM
#3
bsmithtts avatar

bsmithtts

New Zenner

Join Date:
Apr 2008
Location:
Arkansas
Posts:
6
Plugin Contributions:
0

Re: Call username and cart total in template

It will need to be called in the tpl_main_page.php file.

What I am doing is this:
• When logged out, in the upper right hand corner of the template it says "Welcome Guest! Sign In or Register."
• When logged in, I need that to change to something like "Welcome Mr. Smith! Your cart total is now $0.00"
• Or it could say "You are logged in as [email protected]. You have 0 items in your cart".

Username or email address would be fine, as would cart total $ amount or # of items. Which ever is easier to do... the client is not that picky, we just need it to change and have more funtion then just "You are logged in" (which is what I have now)

I have the logic in place to check to see if they are logged in and change what is displayed. But I do not know where to find (or the code) to pull only the items I need into a sentence in the code.

Thank you for your help.

  • Brian Smith
    "Worry is a misuse of imagination" - Dan Zadra
24 Apr 2008, 1:07 PM
#4
bsmithtts avatar

bsmithtts

New Zenner

Join Date:
Apr 2008
Location:
Arkansas
Posts:
6
Plugin Contributions:
0

Re: Call username and cart total in template

by the way, I see this in the language index file:

define('TEXT_GREETING_PERSONAL', 'Hello <span class="greetUser">%s</span>! Would you like to see our <a href="%s">newest additions</a>?');

I figure I need to do something like this, but again... I am just missing the direction needed to develop an edited version for my needs.

I would even search the "developers tool kit" to find the logic, if I could only figure out what part of the logic is.

Thanks again for any help given.

  • Brian
  • Brian Smith
    "Worry is a misuse of imagination" - Dan Zadra
24 Apr 2008, 1:46 PM
#5
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Call username and cart total in template

From /includes/languages/english/index.php

define('TEXT_GREETING_PERSONAL', 'Hello <span class="greetUser">%s</span>! Would you like to see our <a href="%s">newest additions</a>?');

This returns a logged in users first name
From /includes/templates/sideboxes/tpl_shopping_cart.php

$content .= '<div class="cartBoxTotal">' . $currencies->format($_SESSION['cart']->show_total()) . '</div>';

returns cart total

Zen-Venom Get Bitten

24 Apr 2008, 2:01 PM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Call username and cart total in template

Logic in response to your last post:

in languages the index.php has defines that you will copy/move to header.php

then in the functions_customers.php file see the linkage - as this already exists you can just use it
cart total will be different

Zen-Venom Get Bitten

24 Apr 2008, 2:39 PM
#7
bsmithtts avatar

bsmithtts

New Zenner

Join Date:
Apr 2008
Location:
Arkansas
Posts:
6
Plugin Contributions:
0

Re: Call username and cart total in template

Thank you very much for your help.

  • Brian Smith
    "Worry is a misuse of imagination" - Dan Zadra
24 Apr 2008, 4:25 PM
#8
bsmithtts avatar

bsmithtts

New Zenner

Join Date:
Apr 2008
Location:
Arkansas
Posts:
6
Plugin Contributions:
0

Re: Call username and cart total in template

ok... I got the amount to work, but not the name.

Is there something like this available?

<?php echo $_SESSION['customers_firstname']; ?>

I can't seem to find where the name is defined in the session...

  • Brian Smith
    "Worry is a misuse of imagination" - Dan Zadra
24 Apr 2008, 4:36 PM
#9
bsmithtts avatar

bsmithtts

New Zenner

Join Date:
Apr 2008
Location:
Arkansas
Posts:
6
Plugin Contributions:
0

Re: Call username and cart total in template

Nevermind...

Found it.

<?php echo $_SESSION['customer_first_name'] ?>

Thanks again!

  • Brian Smith
    "Worry is a misuse of imagination" - Dan Zadra
12 May 2008, 12:16 AM
#10
keithdamon avatar

keithdamon

New Zenner

Join Date:
Apr 2008
Posts:
13
Plugin Contributions:
0

Re: Call username and cart total in template

kobra:

From /includes/languages/english/index.php

define('TEXT_GREETING_PERSONAL', 'Hello <span class="greetUser">%s</span>! Would you like to see our <a href="%s">newest additions</a>?');

> This returns a logged in users first name
> From /includes/templates/sideboxes/tpl_shopping_cart.php
> ```
$content .= '<div class="cartBoxTotal">' . $currencies->format($_SESSION['cart']->show_total()) . '</div>';

returns cart total

Can someone please tell me how to remove this from customers logging in.. I would like it to be blank and not ask them to see any newest additions with a link.. I see this line in (/includes/languages/english/index.php) but when I remove it it freezes up the site.. thanks if someone can help me on this..
KeithDamon

12 May 2008, 2:55 AM
#11
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Call username and cart total in template

KeithDamon:

Can someone please tell me how to remove this from customers logging in
I assume you mean the customer greeting -

admin > config > layout settings > Customer Greeting - Show on Index Page > turn off

Zen-Venom Get Bitten