Clear shipping/billing info after checkout

I am taking orders using a public computer.

I can't find a good way to clear shipping/billing info after a customer checks out.

That is to say, after completing an order, the shipping/billing info persists. In fact, we just had an instance where the billing info didn't get replaced even when we put in new shipping info.

We are not using logins.

Thanks in advance.

  • aecnu
    • WP Unicorn

    Greetings standardken,

    Welcome to WPMU DEV!

    Thank you for letting us know and though I personally do not have an answer for this unusual situation, and if this were the case in my neck of the woods, I would have a key logger on it so fast it would make your head spin and you would think you are Linda Blair and this shipping info would be the least of your worries .... lol

    However, I will see if I can get the lead developer in here with his invaluable insight into this plugin for his advice/advise for us.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • standardken
    • New Recruit

    It's a secure computer; we are helping customers place orders, so it will be our staff filling out the forms. But multiple customers' orders will be placed at this computer, one after another, and I want to avoid accidentally applying the previous customer's order info to the next order.

    Anyway, thanks for looking into this.

  • Aaron
    • CTO

    Shipping/billing info is saved in 2 places. If logged in it will be attached to the user. But if logged out it's saved in a cookie. You could simply clear your cookies between orders. Or use private/incognito in your browser. Or maybe there is an extension that can block certain cookies by name.

  • standardken
    • New Recruit

    Clearing cookies itself is a little bit cumbersome, and blocking cookies altogether doesn't allow it to build a cart.

    Private browsing (and just opening new private browsers for each transaction) is not ideal, but probably the best solution—unless there was a simple code tweak to force it to clear the cookie upon order completion.

    Thanks.

  • aecnu
    • WP Unicorn

    Greetings standardken,

    I know it is not ideal but what about setting the browsers home page to your store so each time it is opened the store page is right there and set the browser to clear the cookies each time it is closed?

    How to have the browser do this is of course browser dependent.

    Just trying to come up with a workable solution for you.

    Please advise.

    Cheers, Joe

  • nate_petersen
    • Design Lord, Child of Thor

    Might be a hair of custom coding BUT, I wager we should be able to latch onto an order confirmation hook and insert a bit of javascript that unsets the cookie for that site? Shouldn't be too cumbersome, I recall simply unsetting a site's cookie to be just a line or two of code...

  • nate_petersen
    • Design Lord, Child of Thor

    Plug this into your "mp_cart.php" file, replacing the one line PHP tag with the mp_show_cart function. This should plug this code in at the end of the reporting of the transaction and clear the cookies after the fact.

    <?php
                  $content = mp_show_cart('checkout');
                  $step = get_query_var( 'checkoutstep' );
                  if($step=="success"){
                    $content .= '
                    <javascript>
                    function deleteAllCookies() {
                      var cookies = document.cookie.split(";");
                      for (var i = 0; i < cookies.length; i++) {
                        var cookie = cookies[i];
                        var eqPos = cookie.indexOf("=");
                        var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
                        document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
                       }
                    }
    
                    deleteAllCookies();
                    </script>
                    ';
                  }
                  echo $content;
                ?>
  • nate_petersen
    • Design Lord, Child of Thor

    That one dumps all the cookies for this site that its run on; its just a basic script I turned up from the net on a quick search. I imagine it could be tweaked to clear just the MP cookies; heck, if its just one, the whole effort becomes a lot simpler, all we do is just set that cookie to expire~
    Course, logistically, I think its better to clear all the cookies for the site, just so that the site doesn't naturally hold onto form information.

  • standardken
    • New Recruit

    I dropped the code into mp_cart.php and for whatever reason it didn't work.

    I ended up finding the code in template_functions.php where we clear the cart session variables (mp_payment_method and mp_order) and adding some code to blow up the session altogether.

    session_destroy();
        session_id(session_name(), '', time() - 3600);

    It seems to have worked.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.