Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

два состояния корзины


 Share

Recommended Posts

Всем привет! такой вопрос, как можно реализовать корзину в таком виде?:

1) Если товаров нет, то просто слово корзина

2) Если товар есть, то Корзина, кол-во и сумма.

 

Что надо прописать в cart.tpl? там я написал просто слово корзина и все удалил, и в common.js все подправил. При добавлении товара работает, а когда я перезагружаю страницу или перехожу по ссылке к товару или куда нибудь, опять слово Корзина.

 

Link to comment
Share on other sites


решение то лежало прямо перед глазами...

 

<?php if ($products || $vouchers) { ?>
<span id="cart-total"><?php echo $text_items; ?></span>
<?php } else { ?>
<span class="empty-cart">Корзина</span>
<?php } ?>

 

Но есть одна проблема.

При удалении всех товаров с корзины, остаётся состояние Корзина колво товар, а надо чтобы просто слово корзина была

Edited by redesupar
Link to comment
Share on other sites


как я понял надо тут что то менять

$('#cart > button').html('<span id="cart-total"> ' + json['total'] + '</span>');

но как именно?(

	'remove': function(key) {
		$.ajax({
			url: 'index.php?route=checkout/cart/remove',
			type: 'post',
			data: 'key=' + key,
			dataType: 'json',
			beforeSend: function() {
				$('#cart > button').button('loading');
			},
			complete: function() {
				$('#cart > button').button('reset');
			},
			success: function(json) {
				// Need to set timeout otherwise it wont update the total
				setTimeout(function () {
					$('#cart > button').html('<span id="cart-total"> ' + json['total'] + '</span>');
				}, 100);
				
				var now_location = String(document.location.pathname);

				if ((now_location == '/cart/') || (now_location == '/checkout/') || (getURLVar('route') == 'checkout/cart') || (getURLVar('route') == 'checkout/checkout')) {
					location = 'index.php?route=checkout/cart';
				} else {
					$('#cart > ul').load('index.php?route=common/cart/info ul li');
				}
			},
			error: function(xhr, ajaxOptions, thrownError) {
				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
			}
		});
	}

 

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.