public function column_name(EE_Promotion $item)
 {
     $edit_link = EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'PRO_ID' => $item->ID()), EE_PROMOTIONS_ADMIN_URL);
     $content = EE_Registry::instance()->CAP->current_user_can('ee_edit_promotion', 'espresso_promotions_edit_promotion', $item->ID()) ? '<a href="' . $edit_link . '" title="' . __('Edit Promotion', 'event_espresso') . '">' . $item->name() . '</a>' : $item->name();
     $content .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status(), false, 'sentence') . '</span>';
     return $content;
 }
 /**
  * get_redeemable_scope_promos
  * searches the cart for any items that this promotion applies to
  *
  * @since   1.0.0
  *
  * @param EE_Line_Item $parent_line_item the line item to create the new promotion line item under
  * @param EE_Promotion $promotion        the promotion object that the line item is being created for
  * @param string       $promo_name
  * @param bool         $affects_tax
  * @return \EE_Line_Item
  * @throws \EE_Error
  */
 public function generate_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion, $promo_name = '', $affects_tax = false)
 {
     // verify EE_Line_Item
     if (!$parent_line_item instanceof EE_Line_Item) {
         throw new EE_Error(__('A valid EE_Line_Item object is required to generate a promotion line item.', 'event_espresso'));
     }
     // verify EE_Promotion
     if (!$promotion instanceof EE_Promotion) {
         throw new EE_Error(__('A valid EE_Promotion object is required to generate a promotion line item.', 'event_espresso'));
     }
     $promo_name = !empty($promo_name) ? $promo_name : $promotion->name();
     $promo_desc = $promotion->price()->desc();
     $promo_desc .= $promotion->code() != '' ? ' ( ' . $promotion->code() . ' )' : '';
     // generate promotion line_item
     $line_item = EE_Line_Item::new_instance(array('LIN_code' => 'promotion-' . $promotion->ID(), 'TXN_ID' => $parent_line_item->TXN_ID(), 'LIN_name' => apply_filters('FHEE__EE_Promotion_Scope__generate_promotion_line_item__LIN_name', $promo_name, $promotion), 'LIN_desc' => $promo_desc, 'LIN_unit_price' => $promotion->is_percent() ? 0 : $promotion->amount(), 'LIN_percent' => $promotion->is_percent() ? $promotion->amount() : 0, 'LIN_is_taxable' => $affects_tax, 'LIN_order' => $promotion->price()->order() + EE_Promotion_Scope::$_counter, 'LIN_total' => $promotion->calculated_amount_on_value($parent_line_item->total()), 'LIN_quantity' => 1, 'LIN_parent' => $parent_line_item->ID(), 'LIN_type' => $this->get_promotion_line_item_type(), 'OBJ_ID' => $promotion->ID(), 'OBJ_type' => 'Promotion'));
     EE_Promotion_Scope::$_counter++;
     return $line_item;
 }
 /**
  * verify_no_exclusive_promotions_combined
  * verifies that no exclusive promotions are being combined together
  *
  * @since   1.0.0
  *
  * @param EE_Line_Item $parent_line_item
  * @param EE_Promotion $promotion
  * @return EE_Line_Item
  */
 public function verify_no_exclusive_promotions_combined(EE_Line_Item $parent_line_item, EE_Promotion $promotion)
 {
     /** @type EEM_Line_Item $EEM_Line_Item */
     $EEM_Line_Item = EE_Registry::instance()->load_model('Line_Item');
     // get all existing promotions that have already been added to the cart
     $existing_promotion_line_items = $EEM_Line_Item->get_all_promotion_line_items($parent_line_item);
     if (!empty($existing_promotion_line_items)) {
         // can't apply this new promotion if it is exclusive
         if ($promotion->is_exclusive()) {
             EE_Error::add_attention(sprintf(apply_filters('FHEE__EED_Promotions__verify_no_exclusive_promotions_combined__new_promotion_is_exclusive_notice', __('We\'re sorry, but %3$s have already been added to the cart and the "%1$s%2$s" promotion can not be combined with others.', 'event_espresso')), $promotion->code() ? $promotion->code() . ' : ' : '', $promotion->name(), strtolower($this->_config->label->plural)), __FILE__, __FUNCTION__, __LINE__);
             return false;
         }
         // new promotion is not exclusive...
         // so now determine if any existing ones are
         foreach ($existing_promotion_line_items as $existing_promotion_line_item) {
             if ($existing_promotion_line_item instanceof EE_Line_Item) {
                 $existing_promotion = $this->get_promotion_from_line_item($existing_promotion_line_item);
                 if ($existing_promotion instanceof EE_Promotion && $existing_promotion->is_exclusive()) {
                     EE_Error::add_attention(sprintf(apply_filters('FHEE__EED_Promotions__verify_no_exclusive_promotions_combined__existing_promotion_is_exclusive_notice', __('We\'re sorry, but the "%1$s%2$s" %3$s has already been added to the cart and can not be combined with others.', 'event_espresso')), $existing_promotion->code() ? $existing_promotion->code() . ' : ' : '', $existing_promotion->name(), strtolower($this->_config->label->singular)), __FILE__, __FUNCTION__, __LINE__);
                     return false;
                 }
             }
         }
     }
     return true;
 }