How to import sales from previous SQL DB?

I need to be able to import previous sales from my old web site so that buyers can continue to access downloads they've already purchased.

What are the details of the MarketPress record format so that I can convert the relevant old SQL info into MarketPress sales records so that I can import into the MarketPress / MySQL DB?

  • Ash

    Hello @SirWumpus

    I hope you are well today.

    It won't be easier. As MarketPress doesn't use any external DB tables, it uses WP's core post type structure and meta field to store the data.

    I am tagging an available developer from second level support line in this thread for his valuable opinion on this issue. Please note that, developer response might be slower than usual staff response.


  • Hoang Ngo

    Hi @SirWumpus,

    I hope you are well today and I'm sorry for the delay.

    It's will be very complicate if you do the import by sql only. As for now, you will need to import all the orders, also the relevant products too. Firstly, I will tell you how to import the products.

    A Marketpress(MP) product, is a custom post type, but for import it, we can use the importer tool, you will find the sample file here
    /marketpress/marketpress-includes/sample-marketpress-import.csv, so the task now is query your products, and create a csv file similar to the demo csv. Which can help you import all of the products to marketpress easily

    I assume that, the products have imported. Now we will need to process the orders. MP have a function for us to create the order called create_order, here is how to use

    global $mp;
    $mp->create_order($order_id, $cart, $shipping_info, $payment_info, $paid, $user_id = false, $shipping_total = false, $tax_total = false, $coupon_code = false)

    Parameter details:
    $order_id, this should be null so the MP can auto generate it.
    $cart, This is an array of the cart items, here is example cart array

    array (
      1 =>
      array (
        498 =>
        array (
          0 =>
          array (
            'SKU' => '',
            'name' => 'Product 4',
            'url' => 'http://wpmu/store/products/product-4/',
            'price' => '1123.34',
            'quantity' => 1,
            'download' => false,
        497 =>
        array (
          0 =>
          array (
            'SKU' => '23232',
            'name' => 'Product 3',
            'url' => 'http://wpmu/store/products/product-3/',
            'price' => '2.98',
            'quantity' => 1,
            'download' =>
            array (
              'url' => '',
              'downloaded' => 0,

    $shipping_info, this is an array which hold the information of shipping data, stored in an array, here is example

    			'address1' => '',
    			'address2' => '',
    			'city' => '',
    			'state' => '',
    			'zip' => '',
    			'country' => '',
    			'phone' => '',

    $payment_info, similar to the shipping info, this will hold the payment detail, example how the data should look
    array ( 'gateway_public_name' => 'PayPal', 'gateway_private_name' => 'PayPal Express Checkout', 'method' => 'PayPal balance, Credit Card, or Instant Transfer', 'transaction_id' => '85D714900D8668029', 'status' => array ( 1412932049 => 'Completed: The payment has been completed, and the funds have been added successfully to your account balance.', ), 'currency' => 'USD', 'total' => '1128.51', 'note' => NULL, )
    $paid, from here, it should be true.

    The other, you can let it as default :slight_smile:
    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang Ngo

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.