Monday, 8 February 2016

Show Cart items on Anypage in Opencart using AJAX

1) Open catalog/view/theme/your-theme/template/common/header.tpl 

Items<span id="count-item">(<?php echo $this->cart->countProducts(); ?>)</span>


2) Open catalog/viw/javascript/common.js file

Put this code $('#count-item').html(json['count-item']);   above $('#cart-total').html(json['total']);   

//in function addToCart(product_id, quantity) 



3) Open catalog/controller/checkout/cart.php

Find the given below snippet
$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));

after that put this code

$json['count-item'] = $this->cart->countProducts();$json['count-item'] = $this->cart->countProducts();


No comments:

Post a Comment