Example #1
0
}
########################
###   Let 'er Rip!   ###
########################
###   Here we build our posted contact data and collect the ID   ###
$conID = addCon();
if ($conID != "ERROR") {
    ###   Assuming everything worked lets add the credit card and collect the ID   ###
    $creditID = addCC($conID);
    if ($creditID != "ERROR") {
        ###   Now if nothing errored, lets create a date object for today in the correct format   ###
        $dateObj = date('Ymd\\TH:i:s');
        ###   Then build the order and collect the ID   ###
        $order = buildOrder($conID, "Sample Order", $dateObj, 0, 0);
        if ($order != "ERROR") {
            ###   If the order build was successful lets add our posted products.   ###
            if (isset($_POST['hotDog'])) {
                addOrderItem($order, 41, 4, 2.0, 1, "HOT DOG!", "An All-Beef frank!");
            }
            if (isset($_POST['Burger'])) {
                addOrderItem($order, 42, 4, 3.5, 1, "Hamburger!", "2 Buns and a patty!");
            }
            if (isset($_POST['Fries'])) {
                addOrderItem($order, 43, 4, 1.75, 1, "French Fries!", "Potatoes Fried to perfection!");
            }
            if (isset($_POST['Drink'])) {
                addOrderItem($order, 44, 4, 1.0, 1, "Cold Drink!", "Drink with NO free refills!");
            }
        }
    }
}
        print $result->faultCode() . "<BR>";
        print $result->faultString() . "<BR>";
    }
}
############################################
###   Function to create a blank order   ###
############################################
function buildOrder($cID, $desc, $oDate, $leadAff, $saleAff)
{
    global $client, $key;
    ###Set up the call to add an order to a contact###
    $call = new xmlrpcmsg("InvoiceService.createBlankOrder", array(php_xmlrpc_encode($key), php_xmlrpc_encode($cID), php_xmlrpc_encode($desc), php_xmlrpc_encode($oDate, array('auto_dates')), php_xmlrpc_encode($leadAff), php_xmlrpc_encode($saleAff)));
    ###Send the call###
    $result = $client->send($call);
    if (!$result->faultCode()) {
        $ordID = $result->value();
        print "Blank order built - ID: " . $ordID;
        print "<BR>";
        return $ordID;
    } else {
        print $result->faultCode() . "<BR>";
        print $result->faultString() . "<BR>";
    }
}
#############################################
###   Build the order and add the items   ###
#############################################
$dateObj = date('Ymd\\TH:i:s');
$order = buildOrder(1300, "Sample Order", $dateObj, 0, 0);
addOrderItem($order, 40, 4, 100.35, 2, "Sample Item", "Relax, its just an example!");