我正在为 woocommerce 销售手机批发的客户开发一个主题。客户拥有 mobileshop.bz 的帐户,并且他们有自己的系统,称为 NATM。我能够非常轻松地导入产品,但我需要找到一种方法将订单详细信息从我的客户网站发送到他在 mobileshop 上的帐户。
看来我必须先预订文章,然后创建销售订单,mobileshop 的那个人为我提供了这个代码片段来预订文章
<?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;
这是为了创建SalesOrder
<?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;
我只是问如何将其集成到我的自定义主题本身中,我是否修改代码示例并将其添加到我的functions.php 文件中。
幕布斯6054654