Post by khnaz35 » Fri Oct 05, 2018 1:53 pm

Hello Every one,
I am using OC 2.3.0.2 with Journal 2.9.2 i want to show the total number of product in header cart and it to be update when some one add or remove the product from cart.
My header.php is look like this

Code: Select all

$data['text_shopping_cart'] = $this->language->get('text_shopping_cart');
My language file for cart is this

Code: Select all

<?php
// Text
$_['text_items']     = '%s item(s) - %s';
$_['text_empty']     = 'Your shopping cart is empty!';
$_['text_cart']      = 'View Cart';
$_['text_checkout']  = 'Checkout';
$_['text_recurring'] = 'Payment Profile';
My javascript code is like this

Code: Select all

function getURLVar(key){var value=[];var query=String(document.location).split('?');if(query[1]){var part=query[1].split('&');for(i=0;i<part.length;i++){var data=part[i].split('=');if(data[0]&&data[1]){value[data[0]]=data[1];}}if(value[key]){return value[key];}else{return'';}}}$(document).ready(function(){$('.text-danger').each(function(){var element=$(this).parent().parent();if(element.hasClass('form-group')){element.addClass('has-error');}});$('#form-currency .currency-select').on('click',function(e){e.preventDefault();$('#form-currency input[name=\'code\']').val($(this).attr('name'));$('#form-currency').submit();});$('#form-language .language-select').on('click',function(e){e.preventDefault();$('#form-language input[name=\'code\']').val($(this).attr('name'));$('#form-language').submit();});$('#search input[name=\'search\']').parent().find('button').on('click',function(){var url=$('base').attr('href')+'index.php?route=product/search';var value=$('header #search input[name=\'search\']').val();if(value){url+='&search='+encodeURIComponent(value);}location=url;});$('#search input[name=\'search\']').on('keydown',function(e){if(e.keyCode==13){$('header #search input[name=\'search\']').parent().find('button').trigger('click');}});$('#menu .dropdown-menu').each(function(){var menu=$('#menu').offset();var dropdown=$(this).parent().offset();var i=(dropdown.left+$(this).outerWidth())-(menu.left+$('#menu').outerWidth());if(i>0){$(this).css('margin-left','-'+(i+10)+'px');}});$('#list-view').click(function(){$('#content .product-grid > .clearfix').remove();$('#content .row > .product-grid').attr('class','product-layout product-list col-xs-12');$('#grid-view').removeClass('active');$('#list-view').addClass('active');localStorage.setItem('display','list');});$('#grid-view').click(function(){var cols=$('#column-right, #column-left').length;if(cols==2){$('#content .product-list').attr('class','product-layout product-grid col-lg-6 col-md-6 col-sm-12 col-xs-12');}else if(cols==1){$('#content .product-list').attr('class','product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-12');}else{$('#content .product-list').attr('class','product-layout product-grid col-lg-3 col-md-3 col-sm-6 col-xs-12');}$('#list-view').removeClass('active');$('#grid-view').addClass('active');localStorage.setItem('display','grid');});if(localStorage.getItem('display')=='list'){$('#list-view').trigger('click');$('#list-view').addClass('active');}else{$('#grid-view').trigger('click');$('#grid-view').addClass('active');}$(document).on('keydown','#collapse-checkout-option input[name=\'email\'], #collapse-checkout-option input[name=\'password\']',function(e){if(e.keyCode==13){$('#collapse-checkout-option #button-login').trigger('click');}});$('[data-toggle=\'tooltip\']').tooltip({container:'body'});$(document).ajaxStop(function(){$('[data-toggle=\'tooltip\']').tooltip({container:'body'});});});var cart={'add':function(product_id,quantity){$.ajax({url:'index.php?route=checkout/cart/add',type:'post',data:'product_id='+product_id+'&quantity='+(typeof(quantity)!='undefined'?quantity:1),dataType:'json',beforeSend:function(){$('#cart > button').button('loading');},complete:function(){$('#cart > button').button('reset');},success:function(json){$('.alert, .text-danger').remove();if(json['redirect']){location=json['redirect'];}if(json['success']){$('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> '+json['success']+' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');setTimeout(function(){$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> '+json['total']+'</span>');},100);$('html, body').animate({scrollTop:0},'slow');$('#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);}});},'update':function(key,quantity){$.ajax({url:'index.php?route=checkout/cart/edit',type:'post',data:'key='+key+'&quantity='+(typeof(quantity)!='undefined'?quantity:1),dataType:'json',beforeSend:function(){$('#cart > button').button('loading');},complete:function(){$('#cart > button').button('reset');},success:function(json){setTimeout(function(){$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> '+json['total']+'</span>');},100);if(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);}});},'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){setTimeout(function(){$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> '+json['total']+'</span>');},100);if(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);}});}}
var voucher={'add':function(){},'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){setTimeout(function(){$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> '+json['total']+'</span>');},100);if(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);}});}}
Need help on this one
Last edited by khnaz35 on Sat Oct 06, 2018 12:02 pm, edited 1 time in total.

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by xxvirusxx » Fri Oct 05, 2018 3:19 pm

Try to post on Commercial topic :)

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by khnaz35 » Sat Oct 06, 2018 12:02 pm

xxvirusxx wrote:
Fri Oct 05, 2018 3:19 pm
Try to post on Commercial topic :)
Thanks but no thanks for advice

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by IP_CAM » Sat Oct 06, 2018 12:40 pm

Well, better don't take it personal, just try to understand the System here,
you are using a paid Custom Theme Extension, heavy on Custom Code, not
only in the Theme Section, but all over the Place. And different Versions of
this Theme Extension exist, so, only one could know, after buying such Mods,
or then, one got 'em from some Dark Side Place. But regardless of, how
someone optained that Code, it's not Open Source, one's talking about, and
it therefore legally just does not belong here, but to it's own Place.

But is is, where many problems start, because only registered Users, who
paid, are allowed to partricipate. And because of this, many end up here ... :'(

Still, Oc does not even make a profit out of sales, since this BRAND is not
offered trough the OC Extension Section, so, there is no real Reason, why
someone here should care about. Who's no Supporter, has no Rights ... 8)

But that's only my personal Feelings on such, as a smallminded Swiss,
so, don't take it for granted ;)
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by khnaz35 » Sat Oct 06, 2018 3:28 pm

IP_CAM wrote:
Sat Oct 06, 2018 12:40 pm
Well, better don't take it personal, just try to understand the System here,
you are using a paid Custom Theme Extension, heavy on Custom Code, not
only in the Theme Section, but all over the Place. And different Versions of
this Theme Extension exist, so, only one could know, after buying such Mods,
or then, one got 'em from some Dark Side Place. But regardless of, how
someone optained that Code, it's not Open Source, one's talking about, and
it therefore legally just does not belong here, but to it's own Place.

But is is, where many problems start, because only registered Users, who
paid, are allowed to partricipate. And because of this, many end up here ... :'(

Still, Oc does not even make a profit out of sales, since this BRAND is not
offered trough the OC Extension Section, so, there is no real Reason, why
someone here should care about. Who's no Supporter, has no Rights ... 8)

But that's only my personal Feelings on such, as a smallminded Swiss,
so, don't take it for granted ;)
Ernie
Thanks Erine, So you are suggesting that i should ask from journal theme provider to resolve this for me? I have the valid support from them can do it if its on their end.
BTW i download the OC 2.3.0.2 also to check all the TPL is same, that's why i ask here that if its OC related stuff. Anyway am not a coder i am just a player who love to play learn and help others. :)

Ali

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by cyclops12 » Sun Oct 07, 2018 12:21 am

try looking at the controller/header.php to see what it is calling to display the cart in the default version then you may be able to reproduce this on your journal theme.

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by straightlight » Sun Oct 07, 2018 1:40 am

Take note that showing the total products in header cart could be misleading since the orders also relies specifically on the store IDs meaning a total number of products being shown from one store cannot justify the total order products from multi-stores. Granted, it may be possible to show all the product counts from all stores but all restrictive settings instantiated prior for each stores over their products would still become clueless unless pulling a filter which would also need to be relative when using the API.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by xxvirusxx » Sun Oct 07, 2018 2:54 pm

khnaz35 wrote:
Sat Oct 06, 2018 12:02 pm
Thanks but no thanks for advice
Then wait to someone to help you for free or try to discover yourself by spent many hours for testing and testing, if you wanna learn :)

See extension from here
viewtopic.php?t=162684

Read here and try
viewtopic.php?t=188002

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România
Who is online

Users browsing this forum: No registered users and 43 guests