The are multiple endpoints available for accessing and update the EthosCE cart.
Adding a product to a user's EthosCE cart.
Adding a uc_cart_item
<?php // Login to the site and request the access token $curl = curl_init('http://74.localhost/restws/session/token'); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); // Your web service user credentials goes here. curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); $token = curl_exec($curl); // The token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%" // Send the user creation request, via POST $data = array( 'cart_id' => 213, // The user's uid 'nid' => 70, // The product's nid 'qty' => 1, ); $curl = curl_init("http://74.localhost/uc_cart_item"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json")); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json")); $json = curl_exec($curl); $response = json_decode($json); print_r($response);
Creating an order
Creationg an order
<?php // Login to the site and request the access token $curl = curl_init('http://74.localhost/restws/session/token'); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); // Your web service user credentials goes here. curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); $token = curl_exec($curl); // The token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%" // Send the creation request, via POST $uc_order = array( "uid" => 213, "customer" => 213, // The user's uid "delivery_address" => array( "first_name" => "Tom", "last_name" => "Baker", "company" => "DLC", "street1" => "1520 Locust", "street2" => "Suite 1000", "city" => "Philadelphia", "postal_code" => "19102", "phone" => "215-321-1234", "email" => "webservice_user@dlcdev.com" ), "billing_address" => array( "first_name" => "WS First", "last_name" => "WS Last", "company" => "DLC", "street1" => "1520 Locust", "street2" => "Suite 1000", "city" => "Philadelphia", "postal_code" => "19102", "phone" => "215-321-1234", "email" => "webservice_user@dlcdev.com" ), "order_status" => "completed", "order_total" => 250.00, "primary_email" => "webservice_user@dlcdev.com", "payment_method" => "", "created" => 1471452801, // Unix UTC Timestamp "modified" => 1471452801, // Unix UTC Timestamp "host" => "127.0.0.1", ); $curl = curl_init("http://74.localhost/uc_order"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json")); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($uc_order)); curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json")); $json = curl_exec($curl); $response = json_decode($json);