Jump to content

Replacing content in cart instead of adding to cart


whoppe2001

Recommended Posts

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 🙂

 

 

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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