コード例 #1
0
 /**
  * Adds the line item as a child to this line item. If there is another child line
  * item with the same LIN_code, it is overwritten by this new one
  * @param EE_Line_Item $line_item
  * @return boolean success
  */
 function add_child_line_item(EE_Line_Item $line_item)
 {
     if ($this->ID()) {
         //check for any duplicate line items (with the same code), if so, this replaces it
         $line_item_with_same_code = $this->get_child_line_item($line_item->code());
         if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) {
             $this->delete_child_line_item($line_item_with_same_code->code());
         }
         $line_item->set_parent_ID($this->ID());
         if ($this->TXN_ID()) {
             $line_item->set_TXN_ID($this->TXN_ID());
         }
         return $line_item->save();
     } else {
         $this->_Line_Item[$line_item->code()] = $line_item;
         return TRUE;
     }
 }
 /**
  * _delete_line_item
  *
  * @access public
  * @param \EE_Line_Item $line_item
  * @return boolean
  */
 public static function _delete_line_item(EE_Line_Item $line_item)
 {
     if ($line_item->ID()) {
         return $line_item->delete();
     } else {
         return EE_Registry::instance()->CART->delete_items($line_item->code());
     }
 }
コード例 #3
0
 /**
  * Adds the line item as a child to this line item
  * @param EE_Line_Item $line_item
  * @return void
  */
 function add_child_line_item(EE_Line_Item $line_item)
 {
     if ($this->ID()) {
         $line_item->set_parent_ID($this->ID());
         $line_item->save();
     } else {
         $this->_Line_Item[$line_item->code()] = $line_item;
     }
 }
 /**
  * 	_total_row
  *
  * @param EE_Line_Item $line_item
  * @param string       $text
  * @return mixed
  */
 private function _sub_total_row(EE_Line_Item $line_item, $text = '')
 {
     $html = '';
     if ($line_item->total()) {
         // start of row
         $html = EEH_HTML::tr('', '', 'total_tr odd');
         $text = $line_item->code() == 'pre-tax-subtotal' ? EED_Multi_Event_Registration::$event_cart_name . ' ' . $text : $text;
         // total td
         $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
         // total td
         $total = $line_item->total();
         $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'total jst-rght');
         // end of row
         $html .= EEH_HTML::trx();
     }
     return $html;
 }
    /**
     *    _ticket_qty_input
     *
     * @param EE_Line_Item $line_item
     * @param \EE_Ticket   $ticket
     * @return mixed
     */
    private function _ticket_qty_input(EE_Line_Item $line_item, EE_Ticket $ticket)
    {
        if ($ticket->remaining() - $line_item->quantity()) {
            $disabled = '';
            $disabled_class = '';
            $disabled_style = '';
            $disabled_title = __('add one item', 'event_espresso');
            $query_args = array('event_cart' => 'add_ticket', 'ticket' => $ticket->ID(), 'line_item' => $line_item->code());
        } else {
            $disabled = ' disabled="disabled"';
            $disabled_class = ' disabled';
            $disabled_style = ' style="background-color:#e8e8e8;"';
            $disabled_title = __('there are no more items available', 'event_espresso');
            $query_args = array('event_cart' => 'view');
        }
        return '
	<div class="event-cart-ticket-qty-dv">
		<input type="text"
					id="event-cart-update-txt-qty-' . $line_item->code() . '"
					class="event-cart-update-txt-qty ' . $disabled_class . '"
					name="event_cart_update_txt_qty[' . $ticket->ID() . '][' . $line_item->code() . ']"
					rel="' . $line_item->code() . '"
					value="' . $line_item->quantity() . '"
					' . $disabled . '
					size="3"
		/>
		<span class="event-cart-update-buttons" >
			<a	title = "' . $disabled_title . '"
				class="event-cart-add-ticket-button event-cart-button event-cart-icon-button button' . $disabled_class . '"
				rel = "' . $line_item->code() . '"
				href = "' . add_query_arg($query_args, EE_EVENT_QUEUE_BASE_URL) . '"
				' . $disabled_style . '
				>
				<span class="dashicons dashicons-plus" ></span >
			</a >
			<a	title = "' . __('remove one item', 'event_espresso') . '"
					class="event-cart-remove-ticket-button event-cart-button event-cart-icon-button button"
					rel = "' . $line_item->code() . '"
					href = "' . add_query_arg(array('event_cart' => 'remove_ticket', 'ticket' => $ticket->ID(), 'line_item' => $line_item->code()), EE_EVENT_QUEUE_BASE_URL) . '"
						>
				<span class="dashicons dashicons-minus" ></span >
			</a >
			<a	title="' . __('delete item from event cart', 'event_espresso') . '"
					class="event-cart-delete-ticket-button event-cart-button event-cart-icon-button button"
					rel="' . $line_item->code() . '"
					href="' . add_query_arg(array('event_cart' => 'delete_ticket', 'ticket' => $ticket->ID(), 'line_item' => $line_item->code()), EE_EVENT_QUEUE_BASE_URL) . '"
				>
				<span class="dashicons dashicons-trash"></span>
			</a>
		</span >
	</div>
';
    }
コード例 #6
0
 /**
  * Makes all the line items which are children of $line_item taxable (or not).
  * Does NOT save the line items
  * @param EE_Line_Item $line_item
  * @param string $code_substring_for_whitelist if this string is part of the line item's code
  *  it will be whitelisted (ie, except from becoming taxable)
  * @param boolean $taxable
  */
 public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null)
 {
     if ($code_substring_for_whitelist !== null) {
         $whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false;
     } else {
         $whitelisted = false;
     }
     if ($line_item->is_line_item() && !$whitelisted) {
         $line_item->set_is_taxable($taxable);
     }
     foreach ($line_item->children() as $child_line_item) {
         EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist);
     }
 }
 /**
  *    _item_row
  *
  * @param EE_Line_Item $line_item
  * @return mixed
  */
 private function _item_row(EE_Line_Item $line_item)
 {
     // start of row
     $content = $line_item->name();
     if ($line_item->percent()) {
         $content .= ' ' . $line_item->percent() . ' %';
     } else {
         $content .= ' ' . $line_item->unit_price_no_code();
     }
     $content .= ' ' . $line_item->quantity() . ' = ';
     $content .= $line_item->is_taxable() ? $line_item->total_no_code() . '*' : $line_item->total_no_code();
     // track taxes
     $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
     return EEH_HTML::li($content, 'event-cart-item-list-' . $line_item->code());
 }
コード例 #8
0
 public function update_item(EE_Line_Item $item)
 {
     // check if item exists
     $ticket_items = $this->get_ticket_items();
     if ($ticket_items && $ticket_items->get_child_line_item($item->code())) {
         $ticket_items->add_child_line_item($item);
         return true;
     } else {
         return false;
     }
 }