Jump to content



Latest News: (loading..)

- - - - -

Code for displaying shopping cart total on page?


  • Please log in to reply
15 replies to this topic

#1   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 30 July 2012 - 07:22 PM

ok, on the default code, it echos and draws the buttons for my account, cart, and login.

but if i just want to have the code for shopping basket without any button, what do i need to do?

im not sure how to modify this statement here

				   	 <?php
  echo tep_draw_button(HEADER_TITLE_CART_CONTENTS . ($cart->count_contents() > 0 ? ' (' . $cart->count_contents() . ')' : ''), 'cart',
  tep_href_link(FILENAME_SHOPPING_CART));?>



#2   kymation

kymation

    Believers

  • Community Sponsor
  • 6,690 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 30 July 2012 - 07:25 PM

Just the total count:

<?php
  echo $cart->count_contents(); ?>

Regards
Jim
My Addons

Banners Box 2.3.x  Support
Categories Accordion Box 2.3.x  Support
Categories Images Box 2.2x  2.3.x  Support
Closest Shipper 2.2x  Support
Document Manager 2.2x  Support
Generic Box 2.3.x  Support
Get 1 Free 2.2x  Support
jQuery Banner Rotator 2.2x  2.3.x  Support
Modular Front Page 2.3.x  Support
Modular SEO Header Tags 2.3.x  Support
MVS 2.2x  Support
PDF Datasheet 2.3.x  Support
Price Updater 2.2x
Products Specifications 2.2x  2.3.x  Development Version  Support  Bugs/Suggestions
Request a Review 2.2x - 2.3.x  Support
Similar Products Box 2.2x
Specials Image Overlay 2.3x Support
Theme Switcher 2.3.x  Support

#3   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 30 July 2012 - 09:03 PM

cool thanks

#4   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 30 July 2012 - 09:12 PM

how do i just get rid of just the button in this line?

echo tep_draw_button(HEADER_TITLE_CART_CONTENTS . ($cart->count_contents() > 0 ? ' (' . $cart->count_contents() . ')' : ''), 'cart',
  tep_href_link(FILENAME_SHOPPING_CART));?>

#5   al3ks

al3ks
  • Members
  • 288 posts
  • Real Name:Aleksander
  • Gender:Male
  • Location:UK

Posted 30 July 2012 - 10:06 PM

View Postvampirehunter, on 30 July 2012 - 09:12 PM, said:

how do i just get rid of just the button in this line?

echo tep_draw_button(HEADER_TITLE_CART_CONTENTS . ($cart->count_contents() > 0 ? ' (' . $cart->count_contents() . ')' : ''), 'cart',
  tep_href_link(FILENAME_SHOPPING_CART));?>

depends what you want to do,
if you want to make it a text link instead of button it would look like this:

echo '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '" alt="" >' . HEADER_TITLE_CART_CONTENTS .($cart->count_contents() >= 0 ? ' (' . $cart->count_contents() . ')' : '') . '</a>'; ?>

Edited by al3ks, 30 July 2012 - 10:07 PM.

Find this post helpful? Click the 'Like this' button. :)

#6   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 30 July 2012 - 10:10 PM

thanks, do i do the same for any other icons i want to remove for other links?

also, do you think is better to use the jquery icons or use my own?

the jquery ones are a bit small.

#7   al3ks

al3ks
  • Members
  • 288 posts
  • Real Name:Aleksander
  • Gender:Male
  • Location:UK

Posted 30 July 2012 - 11:45 PM

For other links it would slightly different as the cart link includes number of cart contents.

For other links you'd use something like this, replacing the FILANAME_DEFAULT with a filename to the page you want. And HEADER_TITLE is the text for the link- defined in your language definitions.

<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . HEADER_TITLE . '</a>'; ?>

For pages with SSL


<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'SSL') . '">' . HEADER_TITLE . '</a>'; ?>


to use your own icons you'd have to either assign them one by one to your links or change them in the jquery to bigger ones.

But I'd stay with jquery ones.

Edited by al3ks, 30 July 2012 - 11:46 PM.

Find this post helpful? Click the 'Like this' button. :)

#8   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 31 July 2012 - 08:49 AM

ok thanks.
so if i want my own image in this code, where do i put it?

<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . HEADER_TITLE . '</a>'; ?>

#9   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 31 July 2012 - 08:51 AM

also, whats the standard code for adding links to your pages in your header and footer.

#10   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 31 July 2012 - 10:00 AM

also, how would i add the current basket total into the header?

ideally, woud like this layout

View shopping bag
0 items: £0.00

#11   al3ks

al3ks
  • Members
  • 288 posts
  • Real Name:Aleksander
  • Gender:Male
  • Location:UK

Posted 31 July 2012 - 01:57 PM

View Postvampirehunter, on 31 July 2012 - 08:49 AM, said:

ok thanks.
so if i want my own image in this code, where do i put it?

<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . HEADER_TITLE . '</a>'; ?>

. HEADER_TITLE . is your text so you'd replace that with image. example . tep_image(DIR_WS_IMAGES . 'my-image.png') .

View Postvampirehunter, on 31 July 2012 - 08:51 AM, said:

also, whats the standard code for adding links to your pages in your header and footer.

That's the code I just gave you.

View Postvampirehunter, on 31 July 2012 - 10:00 AM, said:

also, how would i add the current basket total into the header?

ideally, woud like this layout

View shopping bag
0 items: £0.00

You already have a link to cart with number of items you'd add the total you'd call it with something like this:

$cart->show_total()

Find this post helpful? Click the 'Like this' button. :)

#12   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 31 July 2012 - 02:04 PM

hi thanks

i did this for the shopping cart so it currently says "view shopping bag (0)".

ive moved the </a> tag so that the (0) counted total is not hyperlinked, just the text.

but for some reason, i can still hover over the (0) amount and a glove appears as though it is still a hyperlink even though it wont go anywhere? what do i have to do to stop this? its annoying having this glove thing show over it.

here is code
   echo '<li><a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '" alt="" >' . HEADER_TITLE_CART_CONTENTS . '</a>' . ($cart->count_contents() >= 0 ? ' (' . $cart->count_contents() . ')' : '') . '</li>';

I also just tested the code you gave me.

echo '<li>' . $cart->show_total() . '</li>';?>

with that one, same thing happens. a glove appears if you hover over it, even though its not hyperlinked to anywhere. Also, i need to put in a pound sign before the total as no pound sign appears.

whats the php code to pull out the pound sign? or do i have to hardcode it in html? which is better do you think?

Edited by vampirehunter, 31 July 2012 - 02:11 PM.


#13   al3ks

al3ks
  • Members
  • 288 posts
  • Real Name:Aleksander
  • Gender:Male
  • Location:UK

Posted 31 July 2012 - 02:15 PM

I don't know what you have in the rest of your code you might have another <a href tag still open above.

For a pound sign use html codes.
echo '<li>&pound;' . $cart->show_total() . '</li>';?>

Find this post helpful? Click the 'Like this' button. :)

#14   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 31 July 2012 - 02:19 PM

thanks. it was a css issue with cursor pointer for the li tags.

#15   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 31 July 2012 - 03:17 PM

another question.
managed to get my view shopping text and the total showing fine.

just one issue.

if nothing is in basket, price shows just £0.

i need to get it to show £0.00

here's my code

   echo '<li><a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '" alt="" >' . HEADER_TITLE_CART_CONTENTS . '</a></li><br />' . 
   '<li>'.$cart->count_contents().' item(s)&nbsp;&nbsp;<strong> &pound;' . $cart->show_total() . '</strong></li>'; ?>


#16   vampirehunter

vampirehunter
  • Members
  • 274 posts
  • Real Name:vampire

Posted 31 July 2012 - 04:16 PM

and another question.

if i wanted to link a product category rather than a page, how would i do that?