I am developing a theme for a client with woocommerce selling mobile phones wholesale. The client has an account with mobileshop.bz and they have their own system called NATM. I am able to import the products really easily but I need to find a way to send order details from my clients site to his account on mobileshop.
It seems I have to first reserve articles and then create a sales order, the guy’s at mobileshop provided me with this code snippet to reserve an article
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://restful.mobileshop.bz/reserveArticle/new/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array('sku' => '','qty' => ''),
CURLOPT_HTTPHEADER => array(
"Authorization: paste in your API key"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
and this to createSalesOrder
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://restful.mobileshop.bz/createSalesOrder/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array('reservation[]' => '','reservation[]' => '','pay_method' => '','insurance' => '','drop_shipping' => '0','drop_ship[name]' => '','drop_ship[address]' => '','drop_ship[postcode]' => '','drop_ship[city]' => '','drop_ship[country]' => '','drop_ship[contact]' => ''),
CURLOPT_HTTPHEADER => array(
"Authorization: paste in your API key"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
I am just asking how do I integrate this into my custom theme itself, Do I modify the code examples and add it to my functions.php file.
Many thanks,
Phillip Dews
2
Answers
I can see this being one in two ways.
Not a concrete idea but hopefully it can give you can idea on how to approach it.
If you want this to fire on every order use one of WooCommerces hooks and place it in your functions.php file.
That’s how I would approach it. Might need to be tweaked for specific needs and any errors as it’s completely not tested.