/**
  *    adjust_ticket_quantity
  *
  * @access    protected
  * @param EE_Ticket $ticket
  * @param int       $quantity
  * @param bool      $cart_update
  * @return bool
  */
 protected function can_purchase_ticket_quantity(EE_Ticket $ticket, $quantity = 1, $cart_update = false)
 {
     // any tickets left at all?
     $tickets_remaining = $ticket->remaining();
     if (!$tickets_remaining) {
         // event is full
         EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event. No additional attendees can be added.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         return false;
     }
     $quantity = absint($quantity);
     // can't register anymore attendees
     $singular = 'You have attempted to purchase %1$d ticket.';
     $plural = 'You have attempted to purchase %1$d tickets.';
     $limit_error_1 = sprintf(_n($singular, $plural, $quantity, 'event_espresso'), $quantity);
     // is there enough tickets left to satisfy request?
     if ($tickets_remaining < $quantity) {
         // translate and possibly pluralize the error
         $singular = 'There is only %1$d ticket remaining for this event, therefore the total number of tickets you may purchase is %1$d.';
         $plural = 'There are only %1$d tickets remaining for this event, therefore the total number of tickets you may purchase is %1$d.';
         // translate and possibly pluralize the error
         $limit_error_2 = sprintf(_n($singular, $plural, $tickets_remaining, 'event_espresso'), $tickets_remaining);
         EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
         return false;
     }
     // check event
     $total_ticket_quantity_within_event_additional_limit = $this->_total_ticket_quantity_within_event_additional_limit($ticket, $quantity, $cart_update);
     if (!$total_ticket_quantity_within_event_additional_limit) {
         // get some details from the ticket
         $additional_limit = $ticket->first_datetime()->event()->additional_limit();
         // can't register anymore attendees
         $singular = 'You have attempted to purchase %1$d ticket but that would result in too many tickets in the %2$s for this event.';
         $plural = 'You have attempted to purchase %1$d tickets but that would result in too many tickets in the %2$s for this event.';
         $limit_error_1 = sprintf(_n($singular, $plural, $quantity, 'event_espresso'), $quantity, EED_Multi_Event_Registration::$event_cart_name);
         // translate and possibly pluralize the error
         $singular = 'The registration limit for this event is %1$d ticket per transaction, therefore the total number of tickets you may purchase at any time can not exceed %1$d.';
         $plural = 'The registration limit for this event is %1$d tickets per transaction, therefore the total number of tickets you may purchase at any time can not exceed %1$d.';
         // translate and possibly pluralize the error
         $limit_error_2 = sprintf(_n($singular, $plural, $additional_limit, 'event_espresso'), $additional_limit);
         EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
         return false;
     }
     // YEAH !!!
     return true;
 }
    /**
     *    _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>
';
    }