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. External cart queries EthosCE to retrieve the SKU (model) or external ID of each product and populates the external cart.
  7. User completes check out on external cart
  8. External cart enrolls user in purchased courses via EthosCE web services
  9. External cart deletes products from cart via EthosCE web services

...

Code Block
languagephp
titleReturned cart items in $product_list
linenumberstrue
Array
(
    [0] => stdClass Object
        (
            [cart_item_id] => 36
            [cart_id] => 200
            [nid] => 70
            [qty] => 1
            [changed] => 1458745078
            [node] => stdClass Object
                (
                    [uri] => http://your-domain/node/70
                    [id] => 70
                    [resource] => node
                    [uuid] => c8de7a61-0d7c-48b0-b146-289d8ed2524d
                )
        )

    [1] => stdClass Object
        (
            [cart_item_id] => 37
            [cart_id] => 200
            [nid] => 75
            [qty] => 1
            [changed] => 1458745078
            [node] => stdClass Object
                (
                    [uri] => http://your-domain/node/75
                    [id] => 75
                    [resource] => node
                    [uuid] => 289d8ed2524d-48b0-byr6-as34kn4iopwn
                )
        )

)

Looking up the External ID of each item in the cart.

In order to populate the external cart, each course in EthosCE should be linked to a product id in the external system using a key. Typically this key is stored in the External ID field in the course, although the SKU may be used as well. The value of the External ID field can be retreived using the course endpoint.

Code Block
languagephp
<?php
$curl = curl_init('http://your-domain/course.json?nid=75');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "admin:webservicepw"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
// Your session token and content type
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
print curl_exec($curl);


The SKU can be retreived using the node endpoint.

Code Block
languagephp
<?php
$curl = curl_init('http://your-domain/node.json?nid=75');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "admin:webservicepw"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
// Your session token and content type
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
print curl_exec($curl);


Enrolling the user in their purchased courses

...