...
Now that the user has been enrolled in their courses, we must remove the cart items from their session. This can be done by sending individual deletion requests for each cart item, via it's card item identifier.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// Iterate through the products to create the deletion request foreach ($product_list as $product) { $curl = curl_init("http://your-domain.com/uc_cart_item/{$product->nid>cart_item_id}"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE'); curl_setopt($curl, CURLOPT_HTTPHEADER, array("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); $json = curl_exec($curl); $cinfo = curl_getinfo($curl); $response = json_decode($json); if ($cinfo['http_code'] == 200 && empty($response)) { // The entity has been deleted. } else { // An error has occurred. } } |
...