Jump to content

View Cart Icon only when items are in cart


Spirix

Recommended Posts

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}

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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}

Link to comment
Share on other sites

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! :)

Link to comment
Share on other sites

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}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated