Post by smartycutie » Wed Jul 10, 2013 11:08 pm

Hello,

I have the cart link in my header and would like for it to automatically display/update the number of items in the cart when someone adds a product. I am running Opencart 1.551 and you can see the header here:
zivacollection.com
Can someone help me with the code and file that I need to modify? Many thanks in advance!
Last edited by smartycutie on Wed Jul 24, 2013 4:30 am, edited 1 time in total.

Newbie

Posts

Joined
Sat Jun 29, 2013 9:29 am

Post by tora0515 » Mon Jul 15, 2013 2:24 pm

the file you need to modify is:

catalog/view/theme/default/template/common/header.tpl

What you need to get in there is the cart module: put <?php echo $cart; ?> in the header. then just use the style.css and catalog/view/theme/default/template/module/cart.tpl files to make it look how you want it to.



not sure about your theme, so if it throws up an error then you will need to check the header.php controller too.

Active Member

Posts

Joined
Fri Jun 15, 2012 3:05 pm

Post by smartycutie » Wed Jul 17, 2013 10:36 am

tora0515 wrote:the file you need to modify is:

catalog/view/theme/default/template/common/header.tpl

What you need to get in there is the cart module: put <?php echo $cart; ?> in the header. then just use the style.css and catalog/view/theme/default/template/module/cart.tpl files to make it look how you want it to.



not sure about your theme, so if it throws up an error then you will need to check the header.php controller too.
Thanks for your response.When I add in the code into header.tpl it gives me the price and number of items(e.g. $20.00- 2 items) similar to what I removed from the header as I actually did away with the mini cart. I've included a picture of what I'm trying to describe. Thanks again!
example.jpg

example.jpg (12.32 KiB) Viewed 1720 times


Newbie

Posts

Joined
Sat Jun 29, 2013 9:29 am

Post by tora0515 » Wed Jul 17, 2013 1:28 pm

Yup, so take a look at the mini cart code and see how they are getting the (# of items) Or else, you could just style the mini cart to look like the link (ie get rid of the javascript and a bunch of text) Just depends if you like to erase code or write code.

Active Member

Posts

Joined
Fri Jun 15, 2012 3:05 pm

Post by smartycutie » Tue Jul 23, 2013 4:52 am

tora0515 wrote:Yup, so take a look at the mini cart code and see how they are getting the (# of items) Or else, you could just style the mini cart to look like the link (ie get rid of the javascript and a bunch of text) Just depends if you like to erase code or write code.

Excellent, I have deleted code to get it to look like I want it to. One final question though. Is there a way for me to get rid of the popup link that shows whats in the cart when the mini cart info is clicked? I have it down to an empty window but when I try to totally erase the code from catalog/module/cart.tpl it gives my page a fatal error. BTW give me your paypal addy so I can send you a little token of appreciation (you totally saved me from having to spend money on this fix).

Newbie

Posts

Joined
Sat Jun 29, 2013 9:29 am

Post by pprmkr » Tue Jul 23, 2013 1:27 pm

Edit catalog/view/javascript/common.js

Find and delete the code or rename id '#cart':

Code: Select all

	/* Ajax Cart */
	$('#cart > .heading a').live('click', function() {
		$('#cart').addClass('active');
		
		$('#cart').load('index.php?route=module/cart #cart > *');
		
		$('#cart').live('mouseleave', function() {
			$(this).removeClass('active');
		});
	});
	

Or:
Edit catalog/view/theme/YOUR_THEME/template/module/cart.tpl
Remove <a> and </a> from

Code: Select all

<a><span id="cart-total"><?php echo $text_items; ?></span></a>

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by smartycutie » Wed Jul 24, 2013 4:10 am

Phenomenal! Thanks so much pprmkr!

Newbie

Posts

Joined
Sat Jun 29, 2013 9:29 am
Who is online

Users browsing this forum: No registered users and 313 guests