Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. User is logged into EthosCE
  2. User adds a product, or products, to cart
  3. User navigates to their cart, and clicks check out
  4. User is redirected to external cart
  5. External cart queries EthosCE web services to obtain the list of products in the user's cart
  6. User completes check out on external cart
  7. External cart enrolls user in purchased courses via EthosCE web services
  8. External cart deletes products from cart via EthosCE web services


Image Added


The steps which require interaction with EthosCE are:

...

Code Block
languagephp
titleChecking a user's cart
<?php
// Login to the site and request the access token
$curl = curl_init('http://your-domain/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 query request via GET
$curl = curl_init("http://your-domain/uc_cart_item.json?cart_id=200");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
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));

$json = curl_exec($curl);
$response = json_decode($json);
$product_list = $response['list'];

...


This call will return an array of information. In the array, the list value will contain an additional array of cart items, which represent the courses the users have placed in their EthosCE cart. In the array returned the user has added nodes 70 and 75 for purchasing. If the user had no items in their cart, the list value would be empty.

...