public function column_attributes(EE_Promotion $item) { echo $item->is_exclusive() ? '<span class="dashicons dashicons-awards" title="' . __('Exclusive Promotion - can NOT be combined with others', 'event_espresso') . '"></span>' : ''; echo $item->is_global() ? '<span class="dashicons dashicons-admin-site" title="' . __('Global Promotion - applies to ALL scope items', 'event_espresso') . '"></span>' : ''; }
/** * 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; }