MarketPress – Sub-blog orders showing up on main blog too

I’m having a strange issue with Marketpress 2.1.1.

Whenever someone orders a product from one of my client’s sites (i.e. a sub-blog store), I’m also getting an email. And the order is showing up on the main blog as well. That shouldn’t be happening.

The order looks fine on the client site (under Manage Orders), but it’s showing up garbled on the main blog.

Here are a couple of screenshots:

  • DavidM
    • DEV MAN’s Mascot

    Hi nickd32,

    That’s strange, that’s occurring no matter which sub-site the orders are made from, correct?

    Could you let us know which version of WordPress you’re on to start with?

    Also, could you tell us which gateway(s) you’re using?

    I’ll notify the developers to take a look at this too.



  • nickd32
    • The Incredible Code Injector


    I’ve been testing MP on my local WPMS install, since I’m able to duplicate the error locally.

    I’ve removed all plugins (and mu-plugins and network-activated plugins) except for MP on both the main blog and the sub-blog.

    Still getting the double-posting when orders come in.

    The ONLY way I’ve been able to get rid of the error is to disable MarketPress on the main blog. That’s a bummer though, because then I can’t get to the global gateway settings under Network Admin >> Settings >> MarketPress.

  • nickd32
    • The Incredible Code Injector

    Just tried it with the manual gateway, and everything works! So the issue must be with the Paypal Express gateway…

    And to confirm it creates orders on the subblog (with no error), and a copy of the order (with errors in it) on the main blog?

    Yes, that’s correct. It also sends 2x emails to both the blog owner and the new buyer — one email from the subblog (no errors) and one from the main blog (with errors).

    If you want to Skype for a minute, I’m happy to share my screen and show you what’s happening.

  • nickd32
    • The Incredible Code Injector

    Thanks Aaron. I was going to record a video of me replicating the issue, but I can’t get Paypal sandbox to work — I think it’s down for maintenance or something today.

    I keep getting errors while trying to process a transaction through MP (using the Paypal Express gateway).

    It was working fine yesterday, and I haven’t changed the API credentials, so I’m guessing this is on Paypal’s end.

  • nickd32
    • The Incredible Code Injector

    Aaron — This is still a major problem for me.

    Now other store owners within my network are getting false messages about orders received.

    For example, over the weekend someone ordered a product from this site:

    And this site also got an “order notification”

    Hence, I got a panic email from them saying “another order got screwed up” and “it’s not showing up in our Paypal”.

    Any way I could get you to take a look at my setup? I need to get this resolved ASAP.

  • nickd32
    • The Incredible Code Injector

    @aaron – Trying to get some more data from the error logs and/or the var_dump($result); you suggested here

    But it seems like the Paypal Sandbox has suddenly quit working. I keep getting errors on checkout, and I think they’re on the Paypal side.

    There was a problem connecting to PayPal. Please try again.

    There was a problem finalizing your purchase with PayPal. Please go back and try again.

    Whoops, looks like you skipped a step! Please go back and try again.

    This is maddening.

  • nickd32
    • The Incredible Code Injector

    Trying to troubleshoot Paypal Sandbox… I opened a ticket with their tech support, and here’s the response I got.

    Can you please make sure the shopping cart is in Sandbox mode (Live – Production mode disabled) and make sure you are using the correct Sandbox merchant API credentials.

    Yep, I’ve double and triple-checked this.

    If the error persist please provide us a copy of the API request string from you server logs . Please remove the API password from the request.

    How do I do this on a local MAMP install? I’ve checked the built-in error logs (Apache, MYSQL, PHP) and I’ve also got WP_DEBUG on. None of these show any API string requests.

    I will note, however, that my WP_DEBUG log is throwing lots of PHP Notices — some of these may lend some clues.

    This set of logs is from the following procedure. (WP 3.2.1, using vanilla Twentyten theme, with NO plugins or mu-plugins installed except MarketPress 2.1.3)

    1. Starting from the homepage, clicked on “products”

    2. Chose a product, went through shopping cart

    3. Tried to check out with Paypal Sandbox — error.

  • Aaron
    • CTO

    Ok, lets get deep into debugging. First API request string:

    in the paypal express gateway api_call() function add this right after the string is generated (around 1101):


    If you’ve sorted the sandbox issue, lets see how orders are being doubled. Probably best to do this on your live site. Try putting this right inside the top of the create_order() function 2687:

    global $current_blog;
    $debug = var_export($current_blog, true)."n";
    $debug .= var_export(debug_backtrace(), true)."n";
    $debug .= var_export($order_id, true)."n";
    $debug .= var_export($cart, true)."n";
    $debug .= var_export($shipping_info, true)."n";
    $debug .= var_export($payment_info, true)."n";
    $debug .= var_export($paid, true)."n";
    $debug .= var_export($user_id, true)."n";
    wp_mail('', 'MarketPress Debug', $debug);

  • nickd32
    • The Incredible Code Injector

    Paypal tech support verified several of the Sandbox API strings and checked the tokens on each one — they appear to be successful on their end. However, I’m getting errors back in WP.

    Could there be something going wrong with my browser? or PHP _session variable? Something is triggering a cart_checkout_error

  • nickd32
    • The Incredible Code Injector

    OK, I finally got a Sandbox order to go through. Here’s the debug info you asked for.

    NOTES — This was on my local install, rather than my live site.

    Your debug code actually caused me to receive 3 distinct emails, from…

    1. WordPress <> » Saved as TXT file here

    2. Local Skrocket Install <> » Saved as TXT file here

    3. Local Skrocket Install <> » Saved as TXT file here

    Using a text editor, I compared the documents. 1 and 2 have lots of differences, whereas 2 and 3 are only different in 2 places.


    40:64 — ‘cart_cache’ array

    1114:1135 — array

    1153 – ‘transaction_id’ different

    1156 – extra ‘a: a:’ text in array

    1158:1160 – currency/total/note data different

    (etc… Let me know if you want more detail/screenshots of this)


    1114, 4977

  • nickd32
    • The Incredible Code Injector

    I may have found a clue… Looking at my DB tables, I noticed that even though I have the global shopping cart off, I’m still getting these tables showing up in my global DB:




    Is that by design? Seems like products should only show up in their respective sub-blog DBs, like:




  • nickd32
    • The Incredible Code Injector

    Correct. I renamed my plugins and mu-plugins folders, then made a new (blank) folder called plugins and copied MarketPress in there.

    What’s strange is that this behavior is replicated on my live site.

    Do you want to Skype or remote in to my system to see the behavior in more detail?

  • nickd32
    • The Incredible Code Injector

    Any news/breakthroughs/discoveries on this?

    I had another order go through — this time on the live site.

    Here they are the 3 debug emails…

    1. Skyrocket <> »

    2. Skyrocket <> »

    3. Skyrocket <> »

    Comparing version 2 and 3 — there’s only 2 differences… line 1112 and line 4983. (see attached screenshot)

    There were however, several differences between 1 and 2 (again.)

    Also, there were faulty emails generated for this order as well. Here is the one that I got…

  • nickd32
    • The Incredible Code Injector

    Do you want to take a look at my server or databases?

    It got to be one of 3 things – because I’ve tried this without any themes/plugins/mu-plugins installed:

    1. Server config

    2. Strange entries in the database

    3. strange settings in the wp-config.php file

  • pro120
    • Design Lord, Child of Thor

    So I spent a considerable amount of time trying to figure this issue out yesterday.

    I’m running 3.2.1 with sub directory multisite install.

    MarketPress 2.1.5 (was getting the error on 2.1.4 as well)

    All plugins and mu-plugins disabled.

    Paypal pays out correctly to two different sandbox stores during payment_process() but obviously creates the separate orders incorrectly. It creates a bunk received order with a status of received, the same order id, and strange characters in price and descriptions inside the home site blog that no product was purchased from.

    Any thought on the trouble people are having with switch_to_blog()? Tickets are still commented into /wp-includes/ms-blogs.php

    Additionally I’m getting the following error on the confirmation page.

    Warning: sprintf() [function.sprintf]: Too few arguments in /var/www/ on line 501

    Followed by the success message for the first of the two products purchase. The second item in the global_cart array is always the one that doesn’t get its order created correctly.

  • pro120
    • Design Lord, Child of Thor

    Ok, I thought I fixed my problem of not all the orders being created by doing the following, but after testing a few times I’m getting mixed results. Sometimes it works sometimes it doesn’t

    Line: 454 paypal-express.php


    if (is_multisite())

    Replaced With:

    if (is_multisite())

    Its the end bracket of for ($i=0; $i<10; $i++) {

    Now I am still creating a weirdo order in my site’s main blog but for the time being this is fine cause I will have no products in my main store.

    Also fixed the sprintf error by replacing line 502 in paypal-express.php with

    $content .= '<p>' . sprintf(__('Your order(s) for %s store(s) totaling %s were successful.', 'mp'),count($_SESSION['prs']), $mp->format_currency($this->currencyCode, $_SESSION['final_amt'])) . '</p>';

  • pro120
    • Design Lord, Child of Thor

    Ok fixed it for real now with plenty of tests.

    Line: 462 paypal-express.php

    $result = $mp->create_order($_SESSION['mp_order'], $selected_cart[$bid], $shipping_info, $payment_info, $paid);

    Change To:

    $mp->create_order($_SESSION['mp_order'], $selected_cart[$bid], $shipping_info, $payment_info, $paid);

    Not sure why, I’m guessing something to do with switch to blog and the caching of plugin data. Either way I would love to see if this fixes your problems as well nick.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.