Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
0cf587a7 EM |
2 | |
3 | /** | |
4 | * Class CRM_Event_Cart_StateMachine_Checkout | |
5 | */ | |
6a488035 | 6 | class CRM_Event_Cart_StateMachine_Checkout extends CRM_Core_StateMachine { |
90b461f1 | 7 | |
0cf587a7 EM |
8 | /** |
9 | * @param object $controller | |
10 | * @param const|int $action | |
11 | */ | |
00be9182 | 12 | public function __construct($controller, $action = CRM_Core_Action::NONE) { |
6a488035 TO |
13 | parent::__construct($controller, $action); |
14 | ||
15 | $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session(); | |
16 | $cart->load_associations(); | |
17 | if ($cart->is_empty()) { | |
18 | CRM_Core_Error::statusBounce(ts("You don't have any events in you cart. Please add some events."), CRM_Utils_System::url('civicrm/event')); | |
19 | } | |
20 | ||
be2fb01f | 21 | $pages = []; |
353ffa53 | 22 | $is_monetary = FALSE; |
6a488035 TO |
23 | $is_conference = FALSE; |
24 | foreach ($cart->events_in_carts as $event_in_cart) { | |
25 | if ($event_in_cart->event->is_monetary) { | |
26 | $is_monetary = TRUE; | |
27 | } | |
28 | } | |
29 | $pages["CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices"] = NULL; | |
30 | foreach ($cart->events_in_carts as $event_in_cart) { | |
31 | if ($event_in_cart->is_parent_event()) { | |
32 | foreach ($event_in_cart->participants as $participant) { | |
be2fb01f | 33 | $pages["CRM_Event_Cart_Form_Checkout_ConferenceEvents_{$event_in_cart->event_id}_{$participant->id}"] = [ |
6a488035 TO |
34 | 'className' => 'CRM_Event_Cart_Form_Checkout_ConferenceEvents', |
35 | 'title' => "Select {$event_in_cart->event->title} Events For {$participant->email}", | |
be2fb01f | 36 | ]; |
6a488035 TO |
37 | } |
38 | } | |
39 | } | |
40 | $pages["CRM_Event_Cart_Form_Checkout_Payment"] = NULL; | |
41 | $pages["CRM_Event_Cart_Form_Checkout_ThankYou"] = NULL; | |
42 | $this->addSequentialPages($pages, $action); | |
43 | } | |
96025800 | 44 | |
6a488035 | 45 | } |