Jump to content

Display # of items in cart & limit a client's cart / active services


Blu_

Recommended Posts

Hello! I've come to a stump in the road when trying to develop my own WHMCS theme..

 

I've been trying to limit the client's cart so that they are only allowed to have one of the 6 total products. I'm also trying to limit a client's active services.. Let me explain a little more.

 

Basically I'm not sure how to limit a clients active services so that after they order one of the 6 products, and it sets as active, they cannot order another product from the 6 total products.

 

Also, to enforce this I'd like to limit the client's cart to only 1 item.. For example.. If they add item 1 to their cart, and try to add item 2 to their cart it'll replace the original with the new one item and not have both of them in the cart..

 

Let me know if this is possible, i'm really not sure how I could go about this.

 

P.S

 

-is there a way to "call" or "display" the number of items in the clients cart at that given time? I'm not sure if theres a smarty command as I couldn't find it in the documentation.

 

Thanks for reading!

Link to comment
Share on other sites

there's a free addon that can limit products in the cart - i'm unsure if it deals with the current cart, but should prevent them reordering the same product again.

 

https://www.jetserver.net/whmcs-product-limiter

 

the alternative method would be to write a hook, which I guess would be a query to the database to count the number of active products for the logged in client, and then pass it back to the cart...

 

with regards to the number of items in the cart, the threads below might help...

 

http://forum.whmcs.com/showthread.php?70291-Show-Cart-Items-and-Pricing-Project

http://forum.whmcs.com/showthread.php?88643-View-Cart-Icon-only-when-items-are-in-cart

http://forum.whmcs.com/showthread.php?81499-If-cart-has-product-gt-Show-Cart-Link

 

the first is a free addon, but their site will be down until the New Year... the other two will explain about using the session to determine the number of items...

Link to comment
Share on other sites

  • 3 years later...

 

You can replace the continue button in viewcart.tpl with this:

{if $cartitems > 1 || $clientsstats.productsnumactive eq "1"}
                                
                                <div class="text-right">
                                    <a href="#" class="btn btn-success btn-lg btn-checkout disabled" id="checkout">
                                        You already applied!
                                        <i class="fa fa-arrow-right"></i>
                                    </a><br />
                                    
                                </div>
                                {else}
<div class="text-right">
                                    <a href="cart.php?a=checkout" class="btn btn-success btn-lg btn-checkout{if $cartitems == 0} disabled{/if}" id="checkout">
                                        {$LANG.orderForm.checkout}
                                        <i class="fa fa-arrow-right"></i>
                                    </a><br />
                                    
                                </div>
                                
                                {/if}

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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