我試過下面的代碼,並試圖從Android發佈值來下訂單,但每次我在Chrome上測試它時,都會給出http 500錯誤,而Android會給服務器提供錯誤。不知道我在哪裏搞砸,認真的幫助將被appriciated。謝謝 問我是否需要看看android代碼,但我認爲這並不重要,因爲我給$ data中的硬編碼值。無法創建訂單Woocommerce其他Api php
<?php
require_once('lib/woocommerce-api.php');
$pageNum=1;
$pageNum=$_GET['page_num'];
$options = array(
'debug' => true,
'return_as_array' => false,
'validate_url' => false,
'timeout' => 30,
'ssl_verify' => false,
);
try {
$client = new WC_API_Client('https://www.move2mart.com/', 'ck_0afa3a49305683160fe34189553a660053bd4e6239', 'cs_7dc38a7b52c3fdd34qw61e34090be636ae3364b196', $options);
//$data=array();
$data=[
'payment_method' => 'cod',
'payment_method_title' => 'Cash on Delivery',
'set_paid' => false,
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'city' => 'Karachi',
'email' => '[email protected]',
'phone' => '03123121995'
], 'line_items' => [
[
'product_id' => 779,
'quantity' => 1
]
]
];
print_r($client->post('orders', $data));
if($_POST !=null) {
}
else{
echo "Null POST Request";
}
} catch (WC_API_Client_Exception $e) {
echo $e->getMessage() . PHP_EOL;
echo $e->getCode() . PHP_EOL;
if ($e instanceof WC_API_Client_HTTP_Exception) {
print_r($e->get_request());
print_r($e->get_response());
}
}
http://stackoverflow.com/questions/36729701/programmatically-creating-new-order-in-woocommerce/36929630#36929630 –
@MahaDev我正在使用Woocommerce REST API,我不直接在functions.php中編碼或者網站本身。 –
@MahaDev我跟着這個https://woocommerce.github.io/woocommerce-rest-api-docs/?php#order-properties –