/** * add_promotion_objects_for_global_promotions * * if a promotion is global but doesn't already have a corresponding EE_Promotion_Object record, * then this method will create one and add it to the supplied list of $promotion_objects * * @since 1.0.4 * * @param \EE_Promotion_Object[] $promotion_objects * @param \EE_Promotion $promotion * @param \EE_Base_Class[] $objects * @return \EE_Promotion_Object[] */ public function add_promotion_objects_for_global_promotions($promotion_objects, EE_Promotion $promotion, $objects = array()) { $objects = is_array($objects) ? $objects : array($objects); if (!empty($objects)) { foreach ($objects as $object) { if ($object instanceof EE_Base_Class && $promotion instanceof EE_Promotion && $promotion->is_global()) { if (!empty($promotion_objects)) { foreach ($promotion_objects as $promotion_object) { if ($promotion_object instanceof EE_Promotion_Object && $promotion_object->type() == $this->slug && $promotion_object->OBJ_ID() == $object->ID()) { return $promotion_objects; } } } $promotion_obj = EE_Promotion_Object::new_instance(array('PRO_ID' => $promotion->ID(), 'OBJ_ID' => $object->ID(), 'POB_type' => $this->slug, 'POB_used' => 0)); if ($promotion_obj->save()) { $promotion_objects[$promotion_obj->ID()] = $promotion_obj; } } } } return $promotion_objects; }
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>' : ''; }