Search code examples
expressionenginecartthrob

Lingering CartThrob Session


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}

Solution

  • 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).