/** * Creates a default items subtotal line item * @param EE_Line_Item $pre_tax_line_item * @param EE_Transaction $transaction * @param EE_Event $event * @return EE_Line_Item */ public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) { $event_line_item = EE_Line_Item::new_instance(array('LIN_code' => self::get_event_code($event), 'LIN_name' => self::get_event_name($event), 'LIN_desc' => self::get_event_desc($event), 'LIN_type' => EEM_Line_Item::type_sub_total, 'OBJ_type' => 'Event', 'OBJ_ID' => $event instanceof EE_Event ? $event->ID() : 0)); $event_line_item = apply_filters('FHEE__EEH_Line_Item__create_event_subtotal__event_line_item', $event_line_item); self::set_TXN_ID($event_line_item, $transaction); $pre_tax_line_item->add_child_line_item($event_line_item); return $event_line_item; }
/** * 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; }
/** * gets the line item which comprises all the transaction-wide taxes. * Has a side effect of adding this to the total line item * @return EE_Line_Item */ private function _get_subtotal_for_taxes() { $tax_line_item = EE_Line_Item::new_instance(array('LIN_code' => 'taxes', 'LIN_name' => __('Taxes', 'event_espresso'), 'LIN_type' => EEM_Line_Item::type_tax_sub_total)); $this->_grand_total->add_child_line_item($tax_line_item); return $tax_line_item; }
/** * Creates a line item for the taxes subtotal and finds all the tax prices * and applies taxes to it * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total * @param EE_Transaction $transaction * @return EE_Line_Item */ protected static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { $tax_line_item = EE_Line_Item::new_instance(array('LIN_code' => 'taxes', 'LIN_name' => __('Taxes', 'event_espresso'), 'LIN_type' => EEM_Line_Item::type_tax_sub_total)); if ($transaction) { $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); $total_line_item->set_TXN_ID($transaction); } $total_line_item->add_child_line_item($tax_line_item); //and lastly, add the actual taxes self::apply_taxes($total_line_item); return $tax_line_item; }