2

I have a site with a CT store with 1 product. The customer never adds it to their cart, that happens automatically on the page that links them to the cart, using the following tags:

{exp:cartthrob:clear_cart}
{exp:cartthrob:add_to_cart entry_id="xxx" quantity="1" no_tax="yes"}

This code generally ensures that this will be the only item in the cart. The problem is that customers, by putting in the url for the checkout manually, can get past this page on occasion and end up on the checkout page with an empty cart. That should never happen with this site.

I get what the original developers of this site were doing with the above code, and it's 99% reliable, but I'd like to be 100% sure that when a user reaches my checkout page they have this item in their cart exactly once.

Ideas?

3

Can't you place a small if statement to make sure there is something in the cart and if empty redirect to main page where its added automagically. {if cart_empty}redirect{/if} not sure of syntax, purely demonstration

0

@stuartmcd69's answer is correct but it lacks additional details.

Upon redirecting to the new page, you'll want to use the {add_to_cart} tag.

More specifically, it might look something like this:

{exp:cartthrob:add_to_cart entry_id="<product_entry_id>" quantity="1" return="return/page/here"}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.