這是適用於WP電子商務目前唯一的辦法:我不知道任何WP插件,做任何事情,但是從UPS取運費的
- 你必須讓別人寫你自定義的插件,也可以生成運輸摘要並提交給UPS以獲得運輸標籤。
下面是一些代碼,你可以用開始做出這樣的插件
$xmlRequest1='<?xml version="1.0" encoding="ISO-8859-1"?>
<AccessRequest>
<AccessLicenseNumber>ACCESS LICENCE NUMBER</AccessLicenseNumber>
<UserId>UPS USERNAME</UserId>
<Password>UPS PASSWORD</Password>
</AccessRequest>
<?xml version="1.0" encoding="ISO-8859-1"?>
<ShipmentAcceptRequest>
<Request>
<TransactionReference>
<CustomerContext>Customer Comment</CustomerContext>
</TransactionReference>
<RequestAction>ShipAccept</RequestAction>
<RequestOption>1</RequestOption>
</Request>
<ShipmentDigest>SHIPMENT DIGEST</ShipmentDigest>
</ShipmentAcceptRequest>
';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://wwwcie.ups.com/ups.app/xml/ShipAccept");
// uncomment the next line if you get curl error 60: error setting certificate verify locations
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// uncommenting the next line is most likely not necessary in case of error 60
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
//if ($this->logfile) {
// error_log("UPS REQUEST: " . $xmlRequest . "\n", 3, $this->logfile);
//}
$xmlResponse = curl_exec ($ch); // SHIP ACCEPT RESPONSE
//echo curl_errno($ch);
$xml = $xmlResponse;
preg_match_all("/\<ShipmentAcceptResponse\>(.*?)\<\/ShipmentAcceptResponse\>/s",
$xml, $bookblocks);
foreach($bookblocks[1] as $block)
{
preg_match_all("/\<GraphicImage\>(.*?)\<\/GraphicImage\>/",
$block, $author); // GET LABEL
preg_match_all("/\<TrackingNumber\>(.*?)\<\/TrackingNumber\>/",
$block, $tracking); // GET TRACKING NUMBER
//echo($author[1][0]."\n");
}
echo '<img src="data:image/gif;base64,'. $author[1][0]. '"/>';
代碼來源:http://webcollage.wordpress.com/2011/05/13/ups-label-print-with-php/
這裏http://webcollage.wordpress.com/2011/05/10/ups-shipping-confirmation-code-in-php/你會發現貨運文摘看起來像