4 * Class CRM_Event_Cart_Page_CheckoutAJAX
6 class CRM_Event_Cart_Page_CheckoutAJAX
{
7 function add_participant_to_cart() {
8 require 'CRM/Core/Transaction.php';
9 $transaction = new CRM_Core_Transaction();
10 $cart_id = $_GET['cart_id'];
11 $event_id = $_GET['event_id'];
13 $cart = CRM_Event_Cart_BAO_Cart
::find_by_id($_GET['cart_id']);
15 $params_array = array('cart_id' => $cart->id
, 'contact_id' => CRM_Event_Cart_Form_Cart
::find_or_create_contact(), 'event_id' => $event_id);
18 $participant = CRM_Event_Cart_BAO_MerParticipant
::create($params_array);
21 $form = new CRM_Core_Form();
22 $pform = new CRM_Event_Cart_Form_MerParticipant($participant);
23 $pform->appendQuickForm($form);
25 $renderer = $form->getRenderer();
27 $config = CRM_Core_Config
::singleton();
28 $templateDir = $config->templateDir
;
29 if (is_array($templateDir)) {
30 $templateDir = array_pop($templateDir);
32 $requiredTemplate = file_get_contents($templateDir . '/CRM/Form/label.tpl');
33 $renderer->setRequiredTemplate($requiredTemplate);
35 $form->accept($renderer);
36 $template = CRM_Core_Smarty
::singleton();
37 $template->assign('form', $renderer->toArray());
38 $template->assign('participant', $participant);
39 $output = $template->fetch("CRM/Event/Cart/Form/Checkout/Participant.tpl");
40 $transaction->commit();
42 CRM_Utils_System
::civiExit();
45 function remove_participant_from_cart() {
46 $participant = CRM_Event_Cart_BAO_MerParticipant
::get_by_id($_GET['id']);
47 $participant->delete();
49 CRM_Utils_System
::civiExit();