/** * @return EE_Form_Section_Proper */ public function generate_reg_form() { $this->_print_copy_info = FALSE; $primary_registrant = NULL; // autoload Line_Item_Display classes EEH_Autoloader::register_line_item_display_autoloaders(); $Line_Item_Display = new EE_Line_Item_Display(); // calculate taxes $Line_Item_Display->display_line_item($this->checkout->cart->get_grand_total(), array('set_tax_rate' => true)); EE_Registry::instance()->load_helper('Line_Item'); /** @var $subsections EE_Form_Section_Proper[] */ $subsections = array('default_hidden_inputs' => $this->reg_step_hidden_inputs()); $template_args = array('revisit' => $this->checkout->revisit, 'registrations' => array(), 'ticket_count' => array()); // grab the saved registrations from the transaction $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); if ($registrations) { foreach ($registrations as $registration) { if ($registration instanceof EE_Registration) { // can this registration be processed during this visit ? if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); if (!$this->checkout->admin_request) { $template_args['registrations'][$registration->reg_url_link()] = $registration; $template_args['ticket_count'][$registration->ticket()->ID()] = isset($template_args['ticket_count'][$registration->ticket()->ID()]) ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 : 1; $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs($this->checkout->cart->get_grand_total(), 'Ticket', array($registration->ticket()->ID())); $ticket_line_item = is_array($ticket_line_item) ? reset($ticket_line_item) : $ticket_line_item; $template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item($ticket_line_item); } if ($registration->is_primary_registrant()) { $primary_registrant = $registration->reg_url_link(); } } } } // print_copy_info ? if ($primary_registrant && count($registrations) > 1 && !$this->checkout->admin_request) { // TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info ? $this->_copy_attendee_info_form() : $this->_auto_copy_attendee_info(); // generate hidden input if (isset($subsections[$primary_registrant]) && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper) { $subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false); } } } return new EE_Form_Section_Proper(array('name' => $this->reg_form_name(), 'html_id' => $this->reg_form_name(), 'subsections' => $subsections, 'layout_strategy' => $this->checkout->admin_request ? new EE_Div_Per_Section_Layout() : new EE_Template_Layout(array('layout_template_file' => $this->_template, 'template_args' => $template_args)))); }
/** * get_object_line_items_from_cart * searches the line items for any objects that this promotion applies to * * @since 1.0.0 * * @param EE_Line_Item $total_line_item the EE_Cart grand total line item to be searched * @param array $redeemable_scope_promos * @param string $OBJ_type * @return \EE_Line_Item[] */ public function get_object_line_items_from_cart(EE_Line_Item $total_line_item, $redeemable_scope_promos = array(), $OBJ_type = '') { EE_Registry::instance()->load_helper('Line_Item'); $applicable_items = array(); $OBJ_type = empty($OBJ_type) ? $this->slug : $OBJ_type; // check that redeemable scope promos for the requested type exist if (isset($redeemable_scope_promos[$OBJ_type])) { $object_type_line_items = EEH_Line_Item::get_line_items_by_object_type_and_IDs($total_line_item, $OBJ_type, $redeemable_scope_promos[$OBJ_type]); if (is_array($object_type_line_items)) { foreach ($object_type_line_items as $object_type_line_item) { if (apply_filters('FHEE__EE_Promotion_Scope__get_object_line_items_from_cart__is_applicable_item', true, $object_type_line_item)) { $applicable_items[] = $object_type_line_item; } } } } return $applicable_items; }