/**
  * 	_ticket_row
  *
  * @param EE_Line_Item $line_item
  * @return mixed
  */
 private function _ticket_row(EE_Line_Item $line_item)
 {
     $ticket = EEM_Ticket::instance()->get_one_by_ID($line_item->OBJ_ID());
     if ($ticket instanceof EE_Ticket) {
         // start of row
         $html = '';
         $html .= EEH_HTML::tr('', 'event-cart-item-row-' . $line_item->code());
         $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
         $line_item_name = $line_item->is_taxable() ? $line_item->name() . ' * ' : $line_item->name();
         // name td
         $html .= EEH_HTML::td($line_item_name, '', 'ticket info');
         // price td
         $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght');
         // quantity td
         $html .= EEH_HTML::td($line_item->quantity(), '', 'mini-cart-tbl-qty-td jst-cntr');
         // total td
         $html .= EEH_HTML::td($line_item->total_no_code(), '', 'jst-rght');
         // end of row
         $html .= EEH_HTML::trx();
         return $html;
     }
     return null;
 }
 /**
  *    _adjust_line_item_quantity
  *
  * @access    protected
  * @param EE_Line_Item $line_item
  * @param int $quantity
  * @param string $action
  * @return EE_Line_Item|null
  */
 protected function adjust_line_item_quantity($line_item, $quantity = 1, $action = 'add')
 {
     if ($line_item instanceof EE_Line_Item) {
         //EEH_Debug_Tools::printr( $line_item->code(), '$line_item->code()', __FILE__, __LINE__ );
         //EEH_Debug_Tools::printr( $line_item->type(), '$line_item->type()', __FILE__, __LINE__ );
         //EEH_Debug_Tools::printr( $line_item->OBJ_type(), '$line_item->OBJ_type()', __FILE__, __LINE__ );
         //EEH_Debug_Tools::printr( $line_item->OBJ_ID(), '$line_item->OBJ_ID()', __FILE__, __LINE__ );
         //EEH_Debug_Tools::printr( $quantity, '$quantity', __FILE__, __LINE__ );
         //EEH_Debug_Tools::printr( $action, '$action', __FILE__, __LINE__ );
         $quantity = (int) $quantity;
         if ($quantity === 0 && $action == 'update') {
             $_REQUEST['ticket'] = $line_item->OBJ_ID();
             $_REQUEST['line_item'] = $line_item->code();
             $this->delete_ticket(false);
             return $line_item;
         } else {
             if ($quantity > 0) {
                 $additional = 'An additional';
                 $added_or_removed = 'added';
             } else {
                 $additional = 'A ';
                 $added_or_removed = 'removed';
             }
         }
         $quantity = $action == 'update' ? $quantity : $line_item->quantity() + $quantity;
         // update quantity
         $line_item->set_quantity($quantity);
         //it's "proper" to update the sub-line items quantities too, but core can actually fix it if we don't anyways
         if (method_exists('EEH_Line_Item', 'update_quantity')) {
             EEH_Line_Item::update_quantity($line_item, $quantity);
         } else {
             $line_item->set_quantity($quantity);
         }
         //EEH_Debug_Tools::printr( $line_item, '$line_item', __FILE__, __LINE__ );
         $saved = $line_item->ID() ? $line_item->save() : $line_item->quantity() == $quantity;
         if ($saved) {
             if ($action != 'update') {
                 $msg = sprintf(__('%1$s item was successfully %2$s for this event.', 'event_espresso'), $additional, $added_or_removed);
             } else {
                 $msg = __('The quantities were successfully updated for this event.', 'event_espresso');
             }
             // something got added
             if (apply_filters('FHEE__EED_Multi_Event_Registration__display_success_messages', false)) {
                 EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
             }
         } else {
             if ($line_item->quantity() != $quantity) {
                 // nothing added
                 EE_Error::add_error(sprintf(__('%1$s item was not %2$s for this event. Please refresh the page and try it again.', 'event_espresso'), $additional, $added_or_removed), __FILE__, __FUNCTION__, __LINE__);
                 return null;
             }
         }
     }
     return $line_item;
 }
 /**
  * 	_ticket_row
  *
  * @param EE_Line_Item $line_item
  * @param array        $options
  * @return mixed
  */
 private function _ticket_row(EE_Line_Item $line_item, $options = array())
 {
     $ticket = EEM_Ticket::instance()->get_one_by_ID($line_item->OBJ_ID());
     if ($ticket instanceof EE_Ticket) {
         // start of row
         $html = EEH_HTML::tr('', 'event-cart-ticket-row-' . $line_item->ID(), 'event-cart-ticket-row item');
         // name && desc
         $name_and_desc = $line_item->name();
         $name_and_desc .= $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text"> : ' . $line_item->desc() . '</span>' : '';
         $name_and_desc = $line_item->is_taxable() ? $name_and_desc . ' * ' : $name_and_desc;
         // name td
         $html .= EEH_HTML::td($name_and_desc, '', 'ticket info');
         // price td
         $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght');
         // quantity td
         $html .= EEH_HTML::td($this->_ticket_qty_input($line_item, $ticket), '', 'jst-rght');
         // total td
         $html .= EEH_HTML::td($line_item->total_no_code(), '', 'jst-rght');
         // end of row
         $html .= EEH_HTML::trx();
         return $html;
     }
     return null;
 }
コード例 #4
0
 /**
  * Creates a new, unsaved line item from $line_item that factors in the
  * number of billable registrations on $registrations.
  * @param EE_Line_Item      $line_item
  * @return EE_Line_Item
  * @param EE_Registration[] $registrations
  */
 public static function billable_line_item(EE_Line_Item $line_item, $registrations)
 {
     $new_li_fields = $line_item->model_field_array();
     if ($line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() === 'Ticket') {
         $count = 0;
         foreach ($registrations as $registration) {
             if ($line_item->OBJ_ID() === $registration->ticket_ID() && in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment())) {
                 $count++;
             }
         }
         $new_li_fields['LIN_quantity'] = $count;
     }
     //don't set the total. We'll leave that up to the code that calculates it
     unset($new_li_fields['LIN_ID']);
     unset($new_li_fields['LIN_parent']);
     unset($new_li_fields['LIN_total']);
     return EE_Line_Item::new_instance($new_li_fields);
 }
 /**
  *    _process_billable_total
  *
  * @param EE_Line_Item $line_item
  * @return mixed
  */
 private function _is_billable(EE_Line_Item $line_item)
 {
     $billable = 0;
     // is this a ticket ?
     if ($line_item->OBJ_type() == 'Ticket') {
         //echo '<br/><h5 style="color:#2EA2CC;">$line_item->name() : <span style="color:#E76700">' . $line_item->name() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
         //echo '<h5 style="color:#2EA2CC;">$line_item->OBJ_ID() : <span style="color:#E76700">' . $line_item->OBJ_ID() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
         // is it in the "do not bill" list?
         foreach ($this->_billable as $REG_ID => $TKT_ID) {
             if ($line_item->OBJ_ID() === $TKT_ID) {
                 //echo '<h5 style="color:#2EA2CC;">billable : <span style="color:#E76700">' . $line_item->unit_price() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
                 $this->_billable_total += $line_item->unit_price();
                 //$this->_total_items += $line_item->quantity();
                 if ($line_item->is_taxable()) {
                     $this->_billable_tax_total += $line_item->unit_price();
                 }
                 $this->_total_items++;
                 $billable++;
                 unset($this->_do_not_bill[$REG_ID]);
             }
         }
         foreach ($this->_do_not_bill as $REG_ID => $TKT_ID) {
             if ($line_item->OBJ_ID() === $TKT_ID) {
                 //echo '<h5 style="color:#2EA2CC;">non_billable : <span style="color:#E76700">' . $line_item->unit_price() . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
                 $this->_non_billable_total += $line_item->unit_price();
                 if ($line_item->is_taxable()) {
                     $this->_non_billable_tax_total += $line_item->unit_price();
                 }
                 unset($this->_do_not_bill[$REG_ID]);
             }
         }
     }
     return $billable;
 }
 /**
  * 	_ticket_row
  *
  * @param EE_Line_Item $line_item
  * @return mixed
  */
 private function _ticket_row(EE_Line_Item $line_item)
 {
     $ticket = EEM_Ticket::instance()->get_one_by_ID($line_item->OBJ_ID());
     if ($ticket instanceof EE_Ticket) {
         // start of row
         $content = $line_item->name();
         $content .= '<div style="margin:0 0 0 2em; text-align: right;">';
         $content .= ' ' . $line_item->quantity();
         $content .= _x(' x ', 'short form for times, for example: 2 x 4 = 8.', 'event_espresso');
         $content .= $line_item->unit_price_no_code() . ' = ';
         $content .= $line_item->is_taxable() ? $line_item->total_no_code() . '*' : $line_item->total_no_code();
         $content .= '</div>';
         // track taxes
         $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
         return EEH_HTML::li($content, 'event-cart-ticket-list-' . $line_item->code());
     }
     return null;
 }
コード例 #7
0
 /**
  *    add_promotion_line_item
  *
  * @access 	public
  * @param EE_Line_Item $parent_line_item the line item that the new promotion was added to as a child line item
  * @param EE_Line_Item $promotion_line_item the line item representing the new promotion
  * @param EE_Promotion $promotion the promotion object that the line item was created for
  * @return 	boolean
  */
 public function add_promotion_line_item(EE_Line_Item $parent_line_item, EE_Line_Item $promotion_line_item, EE_Promotion $promotion)
 {
     EE_Registry::instance()->load_helper('Line_Item');
     // add it to the cart
     if ($parent_line_item->add_child_line_item($promotion_line_item, false)) {
         if ($promotion->scope_obj()->increment_promotion_scope_uses($promotion, $parent_line_item->OBJ_ID())) {
             return TRUE;
         } else {
             // todo: throw error and revert adding promotion line_item
         }
     }
     return FALSE;
 }