2017-04-27 9 views

答えて

1

Woocommerce REST API DocumentationをWoocommerce REST APIの開発に使用することができます。支払ゲートウェイについては

は、URLの下に参照してください。チェックアウトは以下のURL参照してください
http://woocommerce.github.io/woocommerce-rest-api-docs/#payment-gateways

WooCommerce API: create order and checkout

を、私はこのことができます願っています。

+0

ありがとうLuFFY ,.チェックアウトに関するコードを私に提供してください。 –

+0

@SatyendraPrakashあなたの答えはありますか?はいの場合は、親切に答えを受け入れてください:) – LuFFy

+0

@LuFFyは完了していません。注文は今作成されていますが、発送と請求先住所が空であるため、 –

1

最後に、私はいくつかの研究の後でそれを理解しました。以下は、他の人を助けることがwoocommerceチェックアウトWebサービスのコード取り組んでいる -

/*** Just Copy & Paste and change your varriables **/ 

    //do your initial stuff 
    header('Content-type: application/json'); 
    $json_file=file_get_contents('php://input'); 
    $jsonvalue= json_decode($json_file,true); 

    $user_id = $jsonvalue['user_id']; 
    $product_id = $jsonvalue['product_id']; 
    $quantity = $jsonvalue['quantity'];  

//start order data 
$orderData = array( 
    "order" => array(
    'payment_method' => 'paypal', 
    'payment_method_title' => 'Paypal', 
    'set_paid' => true, 
    "billing_address" => array(
            "first_name" => "bfname", 
            "last_name" => "blname", 
            "company" => "testcompanybilling", 
            "address_1" => "sec8", 
            "address_2" => "e32", 
            "city" => "noida", 
            "state" => "Noida", 
            "postcode" => "99999", 
            "country" => "IN", 
            "email" => "[email protected]", 
            "phone" => "888899999999" 

          ), 
     "shipping_address" => array(
            "first_name" => "sfname", 
            "last_name" => "slname", 
            "company" => "testcompanyshipping", 
            "address_1" => "shakkarpur", 
            "address_2" => "laxminigar", 
            "city" => "New Delhi", 
            "state" => "Delhi", 
            "postcode" => "110092", 
            "country" => "IN", 
            "email" => "[email protected]", 
            "phone" => "11009999" 
          ), 
    "customer_id" => $user_id, 
    "line_items" => array( 
     array(
      "product_id" => $product_id, 
      "quantity" => $quantity 
     ) 
    ) 
    ) 
); 

//Create order usind order data 
$data = $client->orders->create($orderData); 
//echo '<pre>'; 
//print_r($data); 
$result['success']='true'; 
$result['error']="0"; 
$result['msg']='Your order has been successfully placed.'; 
$result['data']=$data; 

echo json_encode($result); ` 

歓声を!

関連する問題