sebsimappus Posted November 23, 2016 Share Posted November 23, 2016 Hello, Would it be possible to update the code for whmcs v6 and 7 {php} //Check product count foreach ($_SESSION['cart']['products'] as $prodkey => $prodval){ //Make sure it is a configured product if ($prodval['noconfig'] != '1'){ //Check product quantity if ($prodval['qty'] > 1){ $cartcount = $cartcount + $prodval['qty']; }else{ $cartcount = $cartcount + count($prodkey); } } } //Check domain count foreach ($_SESSION['cart']['domains'] as $domkey => $domval){ //Check for dnsmanagement field to be sure it is a register or transfer being purchased if (array_key_exists('dnsmanagement', $domval)){ $cartcount = $cartcount + count($domkey); } } //Check addon count foreach ($_SESSION['cart']['addons'] as $addkey => $addval){ $cartcount = $cartcount + count($addkey); } //Check renewals count foreach ($_SESSION['cart']['renewals'] as $addkey => $addval){ $cartcount = $cartcount + count($addkey); } //Create a template tag if cart items are found if ($cartcount){ $this->_tpl_vars['cartcount'] = $cartcount; } {/php} thank you in advance 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 23, 2016 Share Posted November 23, 2016 where would it be used ? there are already existing Smarty variables that will tell you how many items are in the cart. 0 Quote Link to comment Share on other sites More sharing options...
sebsimappus Posted November 24, 2016 Author Share Posted November 24, 2016 Thanks for your feedback, I would like to get the list of services in the basket in the header section. thank you in advance 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 24, 2016 Share Posted November 24, 2016 Hi, it's worth remembering that if you want to know the total counts of the specific types in the cart, then you can access it via Smarty in the template without the need for {php}... {$smarty.session.cart.products|@count} {$smarty.session.cart.domains|@count} {$smarty.session.cart.addons|@count} {$smarty.session.cart.renewals|@count} each variable will give you the specific total of products, domains, addons or renewals... they can be outputted separately or added together to create a total - or you could just use {$smarty.session.cart|@count} or one of the existing Smarty variables that contains the number of cart items... though potentially cart|@count won't necessarily be the same as the existing variables or adding their individual totals. if you need to be even more specific, e.g checking for DNSManagement (though I doubt it's required or a good test of whether it's a reg/tran), then you could use Smarty foreach loops instead to test the arrays. alternatively, you could put the code in a hook, but I assume you've modified header.tpl anyway for this custom output, so there would be little gained in doing that. 0 Quote Link to comment Share on other sites More sharing options...
sebsimappus Posted November 25, 2016 Author Share Posted November 25, 2016 Hello, 1000 Thanks for your help. cordially 0 Quote Link to comment Share on other sites More sharing options...
sebsimappus Posted November 26, 2016 Author Share Posted November 26, 2016 Hello, I have one last question, I use ajaxcart as a shopping basket and I would like to know if it is possible to reload the counters with a js once the service in the basket. I ask this because ajaxcart does not reload the page. thank you in advance 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 26, 2016 Share Posted November 26, 2016 I have one last question, I use ajaxcart as a shopping basket and I would like to know if it is possible to reload the counters with a js once the service in the basket.I ask this because ajaxcart does not reload the page. to be honest, off the top of my head, i'm not sure... since ajaxcart is no longer included with v6 and v7, it's been a while since i've used ajaxcart - I would doubt going forward whether it would be compatible with future WHMCS releases. 0 Quote Link to comment Share on other sites More sharing options...
sebsimappus Posted November 26, 2016 Author Share Posted November 26, 2016 (edited) Hello, Thanks for your feedback, I took it for the trouble of running ajaxcart for whmcs v6 and v7, I confess that it was not easy but the result and not bad, as you can dispute in the screen prints. Whenever you have an idea to update the counter of the header part I am taker. thank you in advance Edited November 27, 2016 by sebsimappus 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.