/**
  * Check if global gift condition is satisfied.
  *
  * @since 1.1.0
  * @access public
  *
  * @return boolean
  */
 protected function _check_global_gift_criteria()
 {
     if ('single_gift' === $this->_wfg_type) {
         return true;
     }
     $gift_criteria = WFG_Settings_Helper::get('global_gift_criteria');
     if (empty($gift_criteria)) {
         return true;
     }
     return WFG_Criteria_Helper::parse_criteria($gift_criteria);
 }
 /**
  * Display gift popup in frontend.
  *
  * @since  0.0.0
  * @access public
  *
  * @return void
  */
 public function display_gifts()
 {
     if (!is_cart()) {
         return;
     }
     if ($this->__gift_item_in_cart()) {
         return;
     }
     self::__get_actual_settings();
     //check gift criteria
     if ('single_gift' !== $this->_wfg_type) {
         $gift_criteria = WFG_Settings_Helper::get('global_gift_criteria');
         if (!empty($gift_criteria)) {
             $criteria = WFG_Criteria_Helper::parse_criteria($gift_criteria);
             if (!$criteria) {
                 return;
             }
         }
     }
     //enqueue required styles for this page
     wp_enqueue_style('wfg-core-styles', plugins_url('/css/wfg-styles.css', dirname(__FILE__)));
     wp_enqueue_style('wfg-template-styles', plugins_url('/templates/default/wfg-default.css', dirname(__FILE__)));
     $items = WFG_Product_Helper::get_cart_products();
     if ($items['count'] >= $this->_minimum_qty) {
         if ($this->_wfg_enabled) {
             if (!empty($this->_wfg_products)) {
                 $wfg_free_products = array();
                 foreach ($this->_wfg_products as $product) {
                     $wfg_free_products[] = WFG_Product_Helper::get_product_details($product);
                 }
                 $localize = array('gifts_allowed' => $this->_wfg_gifts_allowed !== false ? $this->_wfg_gifts_allowed : 1);
                 echo "<script>";
                 echo "/* " . "<![CDATA[ */";
                 echo 'var WFG_SPECIFIC =' . json_encode($localize);
                 echo "/* ]]> */";
                 echo "</script>";
                 include PLUGIN_DIR . 'templates/default/template-default.php';
             }
         }
     }
 }