REDOUANE Posted October 26, 2020 Share Posted October 26, 2020 Hello guys, i want some help, if product exist in cart i don t want to add it to cart, is there a way to stop adding product if it exist in cart? Thank you. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted October 26, 2020 Share Posted October 26, 2020 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 26, 2020 Share Posted October 26, 2020 2 hours ago, REDOUANE said: i want some help, if product exist in cart i don t want to add it to cart, is there a way to stop adding product if it exist in cart? not from settings - so the solution would have to be coded. there used to be a free addon years ago called Product Limiter, and if you are still using an older version of WHMCS, and not using PHP7 or later (so it wouldn't work in WHMCS v8), then I suspect it would still work. @Kian posted a free hook, OneOffProductsDomainRequireProduct - it works with v7, but seems to fail with v8 (using same settings) - probably only needs a minor tweak to make it work with v8. there are also at least two commercial options in Marketplace if you want to throw money at an off-the-shelf solution. 0 Quote Link to comment Share on other sites More sharing options...
REDOUANE Posted October 26, 2020 Author Share Posted October 26, 2020 thank you for your replies guys, but i want it just in cart not for the user, i know that there a product limit for customer, but i want it for session Thank you. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 26, 2020 Share Posted October 26, 2020 1 minute ago, REDOUANE said: but i want it just in cart not for the user, i know that there a product limit for customer, but i want it for session Kian's hook would cover both new and existing users, and they can be treated differently... I assume the same would apply to the commercial solutions too. 0 Quote Link to comment Share on other sites More sharing options...
REDOUANE Posted October 26, 2020 Author Share Posted October 26, 2020 it doesn t work for me, i am using whmcs V7 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 26, 2020 Share Posted October 26, 2020 Just now, REDOUANE said: it doesn t work for me, i am using whmcs V7 hmm.. i'm seeing it working in v7.10... I think you should just need to enter your list of one-off PIDs into the $onetimeProducts array and set $notRepeatable to true. 0 Quote Link to comment Share on other sites More sharing options...
REDOUANE Posted October 27, 2020 Author Share Posted October 27, 2020 Is there a way to get a list of products IDs that we have in cart and put them in javascript file ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 27, 2020 Share Posted October 27, 2020 1 hour ago, REDOUANE said: Is there a way to get a list of products IDs that we have in cart and put them in javascript file ? I take it you still can't get the hook working ? the line below from Kian's hook should give you an array (list) of products in the cart... $productsInCart = array_column($_SESSION['cart']['products'], 'pid'); 0 Quote Link to comment Share on other sites More sharing options...
REDOUANE Posted October 28, 2020 Author Share Posted October 28, 2020 Hi, I have fix it by my side, i am suing a onepagecheckout module, so i have fix it using a jquery code Thank you guys 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.