Spirix Posted April 30, 2014 Share Posted April 30, 2014 Hello, I have custom designed a "View Cart" icon, I would like this icon to appear only when a customer has something in his cart, and go away when nothing is in his cart. Any help on how can I do this? Thanks so much! 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted April 30, 2014 Share Posted April 30, 2014 place the following code inside .tpl file where you need to display your icon: {php}foreach ($_SESSION['cart']['products'] as $prodkey => $prodval){if ($prodval['noconfig'] != '1'){if ($prodval['qty'] > 1){$cartcount = $cartcount + $prodval['qty'];}else{$cartcount = $cartcount + count($prodkey);}}}foreach ($_SESSION['cart']['domains'] as $domkey => $domval){if (array_key_exists('dnsmanagement', $domval)){$cartcount = $cartcount + count($domkey);}}foreach ($_SESSION['cart']['addons'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}foreach ($_SESSION['cart']['renewals'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}if ($cartcount){$this->_tpl_vars['cartcount'] = $cartcount;}{/php} {if $cartcount>0} <a href="cart.php?a=view"> <i class="icon-classname"></i> <span>{$cartcount}</span> </a> {/if} 0 Quote Link to comment Share on other sites More sharing options...
Spirix Posted May 5, 2014 Author Share Posted May 5, 2014 place the following code inside .tpl file where you need to display your icon: {php}foreach ($_SESSION['cart']['products'] as $prodkey => $prodval){if ($prodval['noconfig'] != '1'){if ($prodval['qty'] > 1){$cartcount = $cartcount + $prodval['qty'];}else{$cartcount = $cartcount + count($prodkey);}}}foreach ($_SESSION['cart']['domains'] as $domkey => $domval){if (array_key_exists('dnsmanagement', $domval)){$cartcount = $cartcount + count($domkey);}}foreach ($_SESSION['cart']['addons'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}foreach ($_SESSION['cart']['renewals'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}if ($cartcount){$this->_tpl_vars['cartcount'] = $cartcount;}{/php} {if $cartcount>0} <a href="cart.php?a=view"> <i class="icon-classname"></i> <span>{$cartcount}</span> </a> {/if} Thank you, It works wonderfully, however I would like it to not show up on this page: /cart.php?a=view Any way you can help make it do that? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted May 5, 2014 Share Posted May 5, 2014 you can replace it with: {if $filename!='cart'} {php}foreach ($_SESSION['cart']['products'] as $prodkey => $prodval){if ($prodval['noconfig'] != '1'){if ($prodval['qty'] > 1){$cartcount = $cartcount + $prodval['qty'];}else{$cartcount = $cartcount + count($prodkey);}}}foreach ($_SESSION['cart']['domains'] as $domkey => $domval){if (array_key_exists('dnsmanagement', $domval)){$cartcount = $cartcount + count($domkey);}}foreach ($_SESSION['cart']['addons'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}foreach ($_SESSION['cart']['renewals'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}if ($cartcount){$this->_tpl_vars['cartcount'] = $cartcount;}{/php} {if $cartcount>0} <a href="cart.php?a=view"> <i class="icon-classname"></i> <span>{$cartcount}</span> </a> {/if} {/if} 0 Quote Link to comment Share on other sites More sharing options...
Spirix Posted May 5, 2014 Author Share Posted May 5, 2014 you can replace it with: {if $filename!='cart'} {php}foreach ($_SESSION['cart']['products'] as $prodkey => $prodval){if ($prodval['noconfig'] != '1'){if ($prodval['qty'] > 1){$cartcount = $cartcount + $prodval['qty'];}else{$cartcount = $cartcount + count($prodkey);}}}foreach ($_SESSION['cart']['domains'] as $domkey => $domval){if (array_key_exists('dnsmanagement', $domval)){$cartcount = $cartcount + count($domkey);}}foreach ($_SESSION['cart']['addons'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}foreach ($_SESSION['cart']['renewals'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}if ($cartcount){$this->_tpl_vars['cartcount'] = $cartcount;}{/php} {if $cartcount>0} <a href="cart.php?a=view"> <i class="icon-classname"></i> <span>{$cartcount}</span> </a> {/if} {/if} Hmm, that seems to make it disappear on all the cart.php pages (for example /cart.php?a=add&pid=1) instead of just the "/cart.php?a=view" one. So just to clarify, I need the link/icon I made to show up on all the cart.php pages, except "/cart.php?a=view" Thanks again! 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted May 5, 2014 Share Posted May 5, 2014 then it should be like that: {if $filename=='cart' && $smarty.get.a=='view'} {else} {php}foreach ($_SESSION['cart']['products'] as $prodkey => $prodval){if ($prodval['noconfig'] != '1'){if ($prodval['qty'] > 1){$cartcount = $cartcount + $prodval['qty'];}else{$cartcount = $cartcount + count($prodkey);}}}foreach ($_SESSION['cart']['domains'] as $domkey => $domval){if (array_key_exists('dnsmanagement', $domval)){$cartcount = $cartcount + count($domkey);}}foreach ($_SESSION['cart']['addons'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}foreach ($_SESSION['cart']['renewals'] as $addkey => $addval){$cartcount = $cartcount + count($addkey);}if ($cartcount){$this->_tpl_vars['cartcount'] = $cartcount;}{/php} {if $cartcount>0} <a href="cart.php?a=view"> <i class="icon-classname"></i> <span>{$cartcount}</span> </a> {/if} {/if} 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.