Jump to content

update php tag for whmcs v6 and v7


sebsimappus

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. :?:

Link to comment
Share on other sites

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 by sebsimappus
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