I am building a webshop for a client who makes use of drop shipping service. The customer can place the order on the website and the order will be send to the dropshipper automatically. This is done via a POST request by my server, a XML-code containing all the information about the order and is sent to the dropshipper.

This is what I know so far (but not sure how to execute):

  • The XML-code has to be sent via the POST method to an URL.
  • I need to use the correct API-key and have to make sure the XML structure is located within the “data” POST variable.
  • The POST variable “data” ($_POST[‘data’]) should contain the XML-code. All strings must be UTF-8 encoded.
  • It uses the "advanced output" (advanced), so you will receive a detailed output. The output is a JSON string, a string that can be converted into a PHP array of object easily, using the following PHP code: $outputarray = json_decode($output_string,true);

The JSON string always contains the key “result”. You should check the value of this key to find out whether your order request was successful or not. The value will be “OK” in the case your order was placed successfully, and “FAIL” is an error has occurred.

So it's possible to place orders automatically, via API (XML). However, this requires programming skills, and since my programming skills are still on a basic level, I am wondering if anyone is able to help me out :)

I can sent a test order to a special testaccount, test email and test API. This is my code so far:


// Configuration
$email = 'testorder@testaccount.nl';
$apikey = '123456789';

$apiurl = 'https://www.testurl.nl/';

$xml = '<?xml version="1.0" encoding="UTF-8"?>
            <name>Test Person</name>
            <street>Test Street</street>
            <city>Test city</city>
            <country>The Netherlands</country>

// Check whether the config vars are all set
if(empty($email) || empty($apikey)){
    die('Please enter your config vars');

// Check whether the cURL module has been installed
    die('You do not have the cURL functions installed! Ask your host for more info.');
} else {

// Send the XML request
$postfields = 'data='.$xml;
$ch = curl_init($apiurl);
$result = curl_exec($ch);

if($ch === false || $result === false){
    die('There was a problem with the connection');
} else {
    $json = json_decode($result,true);

    // Success
    if($json['result'] == 'OK'){

        echo '<pre>';
        echo 'The order was successful. The following output was received:'.PHP_EOL;
        echo '</pre>';

    // Failure
    } else {
        echo '<pre>';
        echo 'There was a problem with the order request. The following output was received:'.PHP_EOL;
        echo '</pre>';


Of course I get a big FAIL while trying to run the test order.

Not sure if you need this information... But I am using the plugin WP All Export (http://www.wpallimport.com/export/), which allows me to easily sent XML files. In this plugin I have a XML editor and a Functions editor.

I sincerely hope anyone can help me figure this out!

  • sorry, but if programing skills are not your best feature, then for sure for such a thing you need to hire someone. – Mark Kaplun Aug 15 '17 at 9:07
  • Thank you for your reply. Yes, hiring someone would be my next step. – Celsa92 Aug 15 '17 at 9:41

Browse other questions tagged or ask your own question.