I am trying to remove the mini cart on the header,
and want to put item count number next to "shopping cart" link in the header (under the search box)
so it'd be like
shopping cart (0) | wishlist (0)
I opened controller/common/header.php and modified
['text_cart'] part as
sprintf($this->language->get('text_cart'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0));
This does work for counting items in the cart, but it doesn't let the header automatically update the count when I click the add to cart button. I need to refresh the page to see the updated number.
I want it to be automatically updated like wishlist count..
Can I get help with it please?
and want to put item count number next to "shopping cart" link in the header (under the search box)
so it'd be like
shopping cart (0) | wishlist (0)
I opened controller/common/header.php and modified
['text_cart'] part as
sprintf($this->language->get('text_cart'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0));
This does work for counting items in the cart, but it doesn't let the header automatically update the count when I click the add to cart button. I need to refresh the page to see the updated number.
I want it to be automatically updated like wishlist count..
Can I get help with it please?
I think you need to add id="cart_total" to the link.
-
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS
I had the same issue, after changing the text_items in english/common/header.php, it would still default back to displaying the old text and the price amount. I discovered that also changing text_items in english/checkout/cart.php to the same solved the problem. I'm not super sure why it uses different language files for that.
header.tpl
<a id="mini_cart" href="<?php echo $cart; ?>"><?php echo $text_cart; ?></a>
<!--Add id "mini_cart" to "Shopping Cart", So we can easily change the content by jQuery script -->
Modify common.js
addCart function:
removeCart function:
Now we can see Shopping Cart(nnn) under the search area. And any time we update cart, the num changes.
But when there is no change for cart, for example: first enter the home page, or reenter the page, it will display "shopping Cart" without num of items.
I will keep working on it.
<a id="mini_cart" href="<?php echo $cart; ?>"><?php echo $text_cart; ?></a>
<!--Add id "mini_cart" to "Shopping Cart", So we can easily change the content by jQuery script -->
Code: Select all
<div class="links"><a href="<?php echo $home; ?>"><?php echo $text_home; ?></a><a href="<?php echo $wishlist; ?>" id="wishlist_total"><?php echo $text_wishlist; ?></a><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a>
<a id="mini_cart" href="<?php echo $cart; ?>"><?php echo $text_cart; ?></a>
<!--Add id "mini_cart" to "Shopping Cart", So we can easily change the content by jQuery script -->
<a href="<?php echo $checkout; ?>"><?php echo $text_checkout; ?></a></div>
addCart function:
Code: Select all
function addToCart(product_id) {
$.ajax({
url: 'index.php?route=checkout/cart/update',
type: 'post',
data: 'product_id=' + product_id,
dataType: 'json',
success: function(json) {
$('.success, .warning, .attention, .information, .error').remove();
if (json['redirect']) {
location = json['redirect'];
}
if (json['error']) {
if (json['error']['warning']) {
$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
}
}
if (json['success']) {
$('#notification').html('<div class="attention" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.attention').fadeIn('slow');
$('#cart_total').html(json['total']);
[b]//ADD CODE DEGINNING-----------------------------------
//Show goods Number after "Shopping Cart" nav, like this Shopping Cart (num)
var itemNumLength = json['total'].indexOf('item(s)')-1;
//Get the beginning of string "item(s)", then get the length of goods num.
var itemNum = json['total'].substr( 0 , itemNumLength );
//get the goods num in the cart
//var miniCartContent = $('#mini_cart').html();
$('#mini_cart').html('Shopping Cart ('+itemNum+')');
//END-------------------------------------- Only support one language.[/b] $('html, body').animate({ scrollTop: 0 }, 'slow');
}
}
});
}
Code: Select all
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']);
[b]//ADD CODE DEGINNING-----------------------------------
//Show goods Number after "Shopping Cart" nav, like this Shopping Cart (num)
var itemNumLength = json['total'].indexOf('item(s)')-1;
//Get the beginning of string "item(s)", then get the length of goods num.
var itemNum = json['total'].substr( 0 , itemNumLength );
//get the goods num in the cart
//var miniCartContent = $('#mini_cart').html();
$('#mini_cart').html('Shopping Cart ('+itemNum+')');
//END-------------------------------------- Only support one language.[/b] $('#cart .content').html(json['output']);
}
}
});
}
But when there is no change for cart, for example: first enter the home page, or reenter the page, it will display "shopping Cart" without num of items.
I will keep working on it.
Write less, Do more. Learning jQuery, Javascript, PHP, CSS
Modify "catalog\controller\common\header.php"
$this->data['text_cart'] = sprintf($this->language->get('text_cart'), ($this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0)));
Modify "catalog\language\english\common\header.php"
//$_['text_cart'] = 'Shopping Cart';
$_['text_cart'] = 'Shopping Cart (%s)';
DONE!!!
$this->data['text_cart'] = sprintf($this->language->get('text_cart'), ($this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0)));
Modify "catalog\language\english\common\header.php"
//$_['text_cart'] = 'Shopping Cart';
$_['text_cart'] = 'Shopping Cart (%s)';
DONE!!!
Write less, Do more. Learning jQuery, Javascript, PHP, CSS
It is just jQuery, easier than javascript. In fact it is javascript too. But it is easy to learn, and write less do a lot for you.
jQuery is poision, and I want to do almost everything with jQuery.
jQuery is poision, and I want to do almost everything with jQuery.
Write less, Do more. Learning jQuery, Javascript, PHP, CSS
Any idea on how to get this to work on OC v1.5.3.1
Really need this.
Thanks
Really need this.
Thanks
Unlimited Everything Hosting + Anytime Money Back Guarantee
Only£1.95pm - Limited Time Offer - http://shortlink.info/?cda56b00
Who is online
Users browsing this forum: Amazon [Bot] and 94 guests