/**
  * Validate single gift condition.
  *
  * @since  1.1.0
  * @access protected
  *
  * @return boolean
  */
 protected function _validate_single_gift_condition()
 {
     if ('single_gift' !== $this->_wfg_type) {
         return false;
     }
     $total_items_in_cart = WFG_Product_Helper::get_main_product_count();
     if (1 !== $total_items_in_cart) {
         return false;
     }
     return $this->__remove_gift_products();
 }
 /**
  * Remove gifts if the criteria is invalid.
  *
  * @since  0.0.0
  * @access public
  *
  * @return void
  */
 public function validate_gifts()
 {
     if (!is_cart()) {
         return;
     }
     if (!$this->__gift_item_in_cart()) {
         return;
     }
     self::__get_actual_settings();
     if ('single_gift' === $this->_wfg_type) {
         $total_items_in_cart = WFG_Product_Helper::get_main_product_count();
         if (1 === $total_items_in_cart) {
             foreach (WC()->cart->cart_contents as $key => $content) {
                 $is_gift_product = !empty($content['variation_id']) && (bool) get_post_meta($content['variation_id'], '_wfg_gift_product');
                 if ($is_gift_product && !in_array($content['product_id'], $this->_wfg_products)) {
                     WC()->cart->remove_cart_item($key);
                 }
             }
         }
     }
     $cart_items = WFG_Product_Helper::get_gift_products_in_cart();
     if (!$this->_wfg_criteria || !WFG_Product_Helper::crosscheck_gift_items($cart_items, $this->_wfg_products)) {
         //remove gift products
         $removed = false;
         foreach (WC()->cart->cart_contents as $key => $content) {
             $is_gift_product = !empty($content['variation_id']) && (bool) get_post_meta($content['variation_id'], '_wfg_gift_product');
             if ($is_gift_product) {
                 WC()->cart->remove_cart_item($key);
                 $removed = true;
             }
         }
         if ($removed) {
             $noticeText = WFG_Settings_Helper::get('invalid_condition_text', false, 'global_options');
             if ($noticeText === false) {
                 $noticeText = WFG_Common_Helper::translate('Gift items removed as gift criteria isn\'t fulfilled');
             }
             WFG_Common_Helper::fixed_notice($noticeText);
         }
     }
 }