2

I'm running into a weird issue with CartThrob. Googling and CartThrob forums haven't revealed the answer.

After the cart is sent to the payment gateway, it will return to the template a "state" of either "authorized", "processing", "declined" or "failed".

What I'm finding is this "state" lingers around after browser refreshes, including full (no cache) browser refreshes.

This is mostly an issue with the "authorized" message. The "authorized" message appears when an order has been 100% completed.

What I'm seeing is if I start another order right away and go to the template where this code lives, the "authorized" message is still there. The message eventually goes away... maybe after 10/20 minutes or so. But it should go away immediately in my opinion, right? The order is done. Clear everything.

Is this "state" stored in the CartThrob session? Can I force clear the CartThrob session?

        {exp:cartthrob:submitted_order_info}
            {if authorized}
                   Order complete!
             {if:elseif processing}
                   Your order is being processed!
             {if:elseif declined}
                   Your credit card was declined: {error_message}
             {if:elseif failed}
                   Your payment failed: {error_message}
             {/if}
        {/exp:cartthrob:submitted_order_info}
Adrian Macneil
  • 13,017
  • 5
  • 57
  • 70
Anna_MediaGirl
  • 1,120
  • 13
  • 31

2 Answers2

3

I sometimes find this helps clear cart, it works in similar way to {redirect="blah/blah"}

{exp:cartthrob:clear_cart return="about/stuff" }

And of course segment can help if need to trigger via a link

{if segment_3 == "foo"}
{exp:cartthrob:clear_cart return="about/stuff" }
{/if}
Samsull
  • 419
  • 2
  • 6
3

If you only want this info to show up on the post-checkout page the simplest option would be to add an order_status segment to your gateway return URL and then to only output the submitted_order_info tag if that segment is present.

I'm fairly sure that clear_cart just removes cart contents rather than flushing CT session data entirely (I think that's only ever triggered by logging out).

Dom Stubbs
  • 1,198
  • 7
  • 15
  • I added a "process" segment to my update form {exp:cartthrob:update_cart_form return="checkout/billing/process"} and wrapped the messages in {if segment_3 == "process"}. Did the trick! – Anna_MediaGirl Oct 31 '12 at 20:03