whoppe2001 Posted August 7, 2019 Share Posted August 7, 2019 Hello Guys, My sincere apology if this has been covered already, but I was unable to find it. I would like to simply make it so that when a customer clicks on the product, this will be the only product in the cart. Normally I would link to: https://whmcsurl/cart.php?a=add&pid=3 Any idea which action I could use instead to make sure this is the only item in the cart? https://whmcsurl/cart.php?a=replace&pid=3 for example? Any help is greatly appreciated! Thank you, Fredrik 🙂 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 8, 2019 Share Posted August 8, 2019 Hi Fredrik, 20 hours ago, whoppe2001 said: Any idea which action I could use instead to make sure this is the only item in the cart? I don't think that action exists within WHMCS itself, nor can I think of an addon that does it either - I suppose you could do it with one of the cart hooks that when a second product is added to the cart, it removes the other product in there - but again, I don't think that's been published previously. 0 Quote Link to comment Share on other sites More sharing options...
whoppe2001 Posted August 8, 2019 Author Share Posted August 8, 2019 Not super happy about that, I guess I could make a hook that looks for "emptycart=true" or whatever and empty cart based on that. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 9, 2019 Share Posted August 9, 2019 22 hours ago, whoppe2001 said: I guess I could make a hook that looks for "emptycart=true" or whatever and empty cart based on that. it turns out that such code was posted back in 2010 (so long before I started using WHMCS and my time here!)... fundamentally, the hook still works as shown in that thread, e.g if you add cc=1 to the end of your URL, it will empty the cart before starting the process of adding the newly linked product - these days, it should probably be rewritten as a ClientAreaPageCart hook, but it's a good starting point for your hook, e.g it should be simple enough for you to change cc=1 to emptycart=true if that's what you want to do with it. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 9, 2019 Share Posted August 9, 2019 Alternatively create a jQuey-based cart that simply act as a cointainer of product IDs. This way you don't have to deal with WHMCS and you can freely create your spectacular cart. When the client clicks Checkout you transmit everything to WHMCS via API. In other words you're skipping cart.php. 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.