Post by Simplicity » Sun Oct 02, 2011 2:10 am

I would like to move shopping cart to horizontal mega menu, but don't know how ;D
I managed to put a cart inside <li> and it almost works. I can add, remove products, total is being calculated and message "your cart is empty is shown". Only one thing is missing. Header doesn't update when adding or removing products. Here's the code I modified:

I put this in Mega Menu (because I want my cart to be inline with categories)
/catalog/view/theme/default/template/common/header.tpl

Code: Select all

<li id="cartis"><a><?php echo $text_cart; ?><?php echo $text_items; ?></a>
<div>
<ul>
<div class="content"></div>
</ul>
</div>
</li>
Then edited ID's:
/catalog/view/javascript/common.js

Code: Select all

	/* Ajax Cart */
	$('#cartis > a').bind('mouseenter', function() {		
		$.ajax({
			url: 'index.php?route=checkout/cart/update',
			dataType: 'json',
			success: function(json) {
				if (json['output']) {
					$('#cartis .content').html(json['output']);
				}
			}
		});
	});

function removeCart(key) {
	$.ajax({
		url: 'index.php?route=checkout/cart/update',
		type: 'post',
		data: 'remove=' + key,
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, .information').remove();
			
			if (json['output']) {
				$('#cart_total').html(json['total']);
				
				$('#cartis .content').html(json['output']);
			}			
		}
	});
}

function removeVoucher(key) {
	$.ajax({
		url: 'index.php?route=checkout/cart/update',
		type: 'post',
		data: 'voucher=' + key,
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, .information').remove();
			
			if (json['output']) {
				$('#cart_total').html(json['total']);
				
				$('#cartis .content').html(json['output']);
			}			
		}
	});
}
As you see, I only modified HTML, because I can't code PHP. Could someone help me with this? :)

New member

Posts

Joined
Fri Mar 11, 2011 6:26 am

Post by Simplicity » Sun Oct 02, 2011 7:58 pm

Solved :)
Thank you for your help ;D

New member

Posts

Joined
Fri Mar 11, 2011 6:26 am

Post by sladekcze » Sun Nov 26, 2017 8:26 pm

I know it has been a while but ... how did you do that? I have the same problem...

Newbie

Posts

Joined
Sun Nov 26, 2017 5:24 am
Who is online

Users browsing this forum: No registered users and 31 guests