403Webshell
Server IP : 138.197.176.125  /  Your IP : 216.73.217.122
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.3.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/jetcounter/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/jetcounter/woo-scalla.php
<?php
/*
 * Plugin Name: Integration for WooCommerce and ScallaCRM
 * Description: Integrates WooCommerce with ScallaCRM allowing new orders to be automatically sent to your ScallaCRM account.
 * Version: 1.3.2
 * Requires at least: 4.7
 * Tested up to: 6.1
 * WC requires at least: 3.0
 * WC tested up to: 7.0
 * Author: Herry
 * Text Domain: woo-scalla
 * Domain Path: /languages/
 *
 * Copyright: � 2022 Herry, Inc
 *
 */
// Exit if accessed directly
if (!defined("ABSPATH")) {
    exit();
}
 /*ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);*/
if (!class_exists("vxc_vtiger")):
    class vxc_vtiger
    {
        public $url = "";
        public $id = "vxc_vtiger";
        public $domain = "vxc-vtiger";
        public $crm_name = "vtiger";
        public $version = "1.3.2";
        public $min_wc_version = "3.0";
        public $update_id = "50003";
        public $type = "vxc_vtiger_pro";
        public static $processing_feed; 
        public static $all_feeds;  
        public static $feeds_res; 
        public $user = "";
        public static $_order;   
        public static $path = "";
        public static $slug = "";
        public static $base_url = "";
        public static $tooltips = "";
        public static $wc_status;
        public static $wc_status_msg;
        private $plugin_dir;
        private $filter_condition;
        public static $order;
        private $temp = "";
        public static $note = "";
        public static $title = "WooCommerce ScallaCRM Plugin";
        public static $wp_user_update=0;
        public static $wp_product_update=array(); 
        public function instance()
        {
            add_action("plugins_loaded", [$this, "setup_main"]);
            if (is_admin()) {
                add_action("init", [$this, "init"]);
                register_activation_hook(__FILE__, [$this, "activate"]);
            }
        }

        public function setup_main()
        {
            // hook into woocommerce order status changed hook to handle the desired subscription event trigger
            add_action("woocommerce_order_status_changed",    [$this, "status_changed"], 10,  3 );
            add_action( "ywraq_after_create_order", [$this, "quote_created"], 10, 3 );
            add_action(  "woocommerce_subscription_status_updated", [$this, "status_changed_subscription" ],  10, 3 );
            add_action( "woocommerce_checkout_update_order_meta",  [$this, "order_submit"], 99, 2 );
            add_action("woocommerce_new_order", [$this, "order_submit_new"]); //order_id
             //save user
            add_action("profile_update", [$this, "profile_update_set"], 999);
            add_action("user_register", [$this, "profile_update_set"], 999);
            add_action("shutdown", [$this, "profile_update"], 40);
            //add_action('save_post_product',array($this,'save_product'),999,2); //does not support meta fields(old value)
            add_action('woocommerce_update_product',array($this,'save_product'),999,2);
            add_action( "woocommerce_new_product", [$this, "new_product"], 999, 2 );
            add_action( "woocommerce_save_product_variation", [$this, "save_variation"], 999 );
            add_action( "woocommerce_saved_order_items", [$this, "save_lines"], 999, 2 );
        }

        public function profile_update()
        {
            //if(!defined('WC_DOING_AJAX')){ // ! empty( $_GET['wc-ajax'] )
            if (!empty(self::$wp_user_update)) {
                $this->push(self::$wp_user_update, "save_user");
            }
        }
        public function profile_update_set($user_id)
        {
            self::$wp_user_update = $user_id;
        }

        public function new_product($post_id, $product)
        {
           // $this->__log(array('new_product'=>$post_id));
            if ( method_exists($product, "get_status") && $product->get_status() == "publish"
            ) {
                $res = $this->push($post_id, "save_product");
            }
        }
        public function plugin_dir_name(){
          if(!empty($this->plugin_dir)){
          return $this->plugin_dir;
          }
      }
        public function log_msg($msg){
           if ( class_exists( 'WC_Logger' ) ) {
              $logger = new WC_Logger();
              $slug=$this->plugin_dir_name();
              $logger->add( $slug, $msg);
           }
        }

        public function get_item_attrs($item){
        $meta_data=$item->get_meta_data(); $item_info=array();
        foreach ( $meta_data as $meta ) {
            if ( empty( $meta->id ) || '' === $meta->value || ! is_scalar( $meta->value ) || substr( $meta->key, 0, 1 ) == '_' ) {
                continue;
            }

            $meta->key     = rawurldecode( (string) $meta->key );
            $meta->value   = rawurldecode( (string) $meta->value );
            $attribute_key = str_replace( 'attribute_', '', $meta->key );
              $product=$item->get_product();
            $display_key   = wc_attribute_label( $attribute_key, $product );
            $display_value = wp_kses_post( $meta->value );

            if ( taxonomy_exists( $attribute_key ) ) {
                $term = get_term_by( 'slug', $meta->value, $attribute_key );
                if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) {
                    $display_value = $term->name;
                }
            }
            $item_info[$display_key]=$display_value;

        }
           return $item_info;        
        }
        public function process_tags($value,$item=array()){
  //starts with { and ends } , any char in brackets except {
              preg_match_all('/\{[^\{]+\}/',$value,$matches);
              if(!empty($matches[0])){
                  $vals=array();
               foreach($matches[0] as $m){
                   $m=trim($m,'{}'); 
                   $val_cust=$this->get_field_val(array('field'=>$m),$item);
                   if(is_array($val_cust)){ $val_cust=trim(implode(' ',$val_cust)); }   
                $vals['{'.$m.'}']=$val_cust;  
               }
               
              $value=str_replace(array_keys($vals),array_values($vals),$value);
              }

              return $value;
        }
        public function save_product($post_id, $product = "")
        {
             if ( !isset(self::$wp_product_update[$post_id])  ) {
                //if(empty($product)){
                $product = wc_get_product($post_id);
                //}
                //$this->__log(array('save_product'=>$product));
                //var_dump($product); die('------------------');
                if ( is_object($product) &&  method_exists($product, "get_status") &&
                    $product->get_status() == "publish" && !in_array($product->get_type(),array('variable'))) {
                    //do not run with cron becuase our pluin's sync cron creates new zoho product in woo , which is again sent to zoho
                    $res = $this->push($post_id, "save_product");
                    self::$wp_product_update[$post_id] = "";
                }

            }
        }


        public function push($order_id, $status = "user", $log = [])
         {
            //$this->__log(array("push",$order_id, $status , $log));
            global $wpdb;
            $log_id = "";
            self::$processing_feed = true;
            if (empty(self::$all_feeds)) {
                $table = $this->get_table_name("fieldmapping");
                $sql = "SELECT * FROM `$table` ORDER BY object ";
                self::$all_feeds = $wpdb->get_results($sql, ARRAY_A);
            }
            $feeds = self::$all_feeds;
            $table = $this->get_table_name("accounts");
            $account = $wpdb->get_row("SELECT * FROM " . $table ." where status !='9' ", ARRAY_A );
               //var_dump($feeds); die();
             //$status="submit";
             $other_events = ["save_user", "save_product"];
             $is_order = true;
             $item = [];

             $feeds_meta = [];
             self::$feeds_res = [];
             $k = 1000;
             $e = 2000;
             $f = 3000;
             $i = 1;
              //$this->__log(array("push","2"));

             foreach ($feeds as $fd) {
                 $feed= json_decode($fd['meta'],true);
                 $object = $this->post("object", $feed);
                 $event = $this->post("event", $feed);
                 if (!is_array($feed)) {
                     continue;
                 }
                 if ( in_array($status, $other_events) && !in_array($event, $other_events) ) {
                     // if saving user or product , skip all other evnts
                     continue;
                 }
                 if ( $status == "" && (in_array($event, $other_events) || strpos($event, "vxswc-") === 0)  ) { 
                    continue;
                 }
                 if ( $status == "update_order" && !in_array($object, ["Invoice", "SalesOrder", "Quotes"  ])  ) {
                     // only allow orders because only order lines updated
                     continue;
                 }
                 //feed["id"] = $id; 
                 $feeds_meta[$i++] = $feed;
             }
             // $this->__log(array("feed3",$feeds));
             if ($status == "update_order") {
                 $status = "update";
             } 
             //echo json_encode($feeds_meta).'--------------<hr>';
             ksort($feeds_meta);
             //var_dump($status,$feeds_meta);
             //echo json_encode($feeds_meta); die();
             if (is_array($feeds_meta) && count($feeds_meta) > 0) {

                  $is_subscription = false;
                 if ( is_object($order_id) && (strpos($status, "vxswc-") === 0 || $status == "admin_sub")){
                     self::$_order = $_order = $order_id;
                     $order_id = $order_id->get_id();
                     $is_subscription = true;
                 }
                 if ($status == "admin_sub") {
                     $status = "";
                 }

                 if (in_array($status, ["save_user"])) {
                     self::$_order = get_user_by("id", esc_attr($order_id));
                 } else {
                     self::$order = $order = get_post_meta($order_id);
                     self::$order["_post_id"] = $order_id;
                 }

                 if (!in_array($status, $other_events)) {
                     if (!empty($order["_billing_email"][0])) {
                         $email = $order["_billing_email"][0];
                         $email_domain = substr($email, strpos($email, "@") + 1);
                         self::$order["_email_domain"] = [$email_domain];
                     }
                     self::$order["_order_id"] = $order_id;
                     if (!$is_subscription) {
                         self::$_order = $_order = new WC_Order($order_id);

                         if ($_order) {
                             self::$order["_order_id"] = $_order->get_order_number(); //get_id();
                         }
                     }

                     $order_status = $_order->get_status();
                     if (!$order_status) {
                       // $this->__log(array("Order #" . $order_id . " - order status is not valid"));
                         $this->log_msg(  "Order #" . $order_id . " - order status is not valid"  );
                         return;
                     }

                     $date = current_time("mysql");
                     if (is_callable(self::$_order, "get_date_created")) {
                         $date = self::$_order->get_date_created()->date("d-M-Y H:i:s");
                     }
                     self::$order["_order_date"] = $date;

                     if (!isset($order["_completed_date"])) {
                         self::$order["_completed_date"] = $date;
                     }

                     self::$order = $order = apply_filters(
                         "vx_crm_post_fields",
                         self::$order,
                         $order_id,
                         "wc",
                         ""
                     );
                 } else {
                     $is_order = false;
                     $key = $status == "save_product" ? "product_id" : "user_id";
                     self::$order["_" . $key] = $order_id;
                     $item = [$key => $order_id];

                    //  $this->__log(array("push","3.5"));
                 }

                 /// $feeds_meta=array($feeds_meta[3],$feeds_meta[2],$feeds_meta[1]);
                 // echo json_encode($feeds_meta); die();

                 $data = $res = $moved = [];
                 $msg = "";
                 $notice = "";
                 $class = "updated";
                 $error = "";
                 $n = 0;
                // $this->__log(array("push","3"));
                 while ($feed = current($feeds_meta)) {
                     /// $this->__log(array("push","3.6"));
                     next($feeds_meta);
                     $current_pos = key($feeds_meta);
                     $n++;
                     //if($n > 10){ die(); }
                     $id = $this->post("id", $feed);
                      // self::$feeds_res[$id]=array();
                     $no_filter = true;
 
                     $info=$this->get_info($account['id']);
                     $api = $this->get_api($info);
                      // $this->__log(array("push","3.2%"));

                     $object = $this->post("object", $feed);
                     $feed["fields"] = $api->get_fields_crm($object);
 
                     $map = $this->post("map", $feed);
                      $fields = isset($feed["fields"]) ? $feed["fields"] : [];
                     if ( !is_array($fields) || count($fields) == 0 || empty($object) ||  empty($object)
                     ) {
                         continue;
                     }
                                         //  $this->__log(array("push","3.4%"));

                     $parent_id = 0;
                     if (isset(self::$order["__vx_parent_id"])) {
                         $parent_id = self::$order["__vx_parent_id"];
                     }
                     $temp = [];
                     $force_send = false;
                     $post_comment = true;
                      //$this->__log(array("push","4%"));
                     //filter optin condition + events
                     if ($status != "") {
                         //it is not submitted by admin
                   //     $this->__log(array("push","4.1%"));
                         if ( in_array($status, [  "restore",  "update",  "delete", "add_note", "delete_note",   ])  ) {
                             
                            
                           //  $this->__log(array("push","4.5%"));
                             if ($status == "delete_note") {
                                 //when deleting note search note object
                                 $search_object = "Note";
                             }
                              

                             if ($status == "restore"  ) {
                                 // only allow successfully deleted records
                                 continue;
                             }
                             if ( in_array($status, ["update", "delete"])  ) {
                                 // only allow successfully sent records
                                 continue;
                             }
                        //      $this->__log(array("push","4.6%"));
                             
                             if ($status != "restore") {
                                 //restore is like normal send to crm
                                  unset($feed["primary_key"]);
                             }
                             $feed["event"] = $status;
                          //$this->__log(array("push","5%"));

                             // add note and save related extra info
                             if ($status == "add_note" && !empty(self::$note)) {
                                 $temp = [
                                     "Title" => [
                                         "label" => "Note Title",
                                         "value" => self::$note["title"],
                                     ],
                                     "Body" => [
                                         "label" => "Note Content",
                                         "value" => self::$note["body"],
                                     ],
                                     "ParentId" => ["value" => $feed["crm_id"]],
                                 ];
                                 $parent_id = self::$note["id"];
                                 
                             }

                             
                             //delete object
                             if ($status == "delete") {
                                 $temp = ["Id" => ["value" => $feed["crm_id"]]];
                             }
                             //
                             if (!in_array($status, ["update", "restore"])) {
                                 //other case settings(add note, delete note, delete)
                                 //do not apply filters on all other cases(add note, delete note, delete)
                                 $force_send = true;
                             }

                             //do not post comment in al other cases
                             $post_comment = false;
                         }
                      //   $this->__log(array("push","6%"));
                         //var_dump(self::$note,$object,$feed['note_object'],$feed['object'],$feed['crm_id'],$feed['event'],$temp,$feed_log); die();
                         // filter on basis of events
                          
                     // $this->__log(array("push","6.5%"));
                         //if user created account
                         if ($status == "user_created") {
                             $user = false;
                             if (method_exists($_order, "get_user")) {
                                 $user = $_order->get_user();
                             }
                             if (!$user) {
                                 continue;
                             }
                         }
                     }

                     //if submitted by admin, $status is empty , so always continue on admin submit button

                    // $this->__log(array("push","6.7%"));

                     if (  isset($feed["map"]) && count($feed["map"]) > 0 ) {
                         if ($is_order) {
                             //add new fields found in map
                             $items = self::$_order->get_items();

                             if (!empty($feed["each_line"])) {
                                 unset($feed["each_line"]);
                                 $items_total = count($items);
                                 if ($items_total > 1) {
                                     $feed_n = $feed;
                                     $f_n = 0;
                                     foreach ($items as $item_k => $itm) {
                                         $f_n++;
                                         if ($f_n > 1) {
                                             $feed_n["_vx_item_id"] = $item_k;
                                             $feeds_meta[] = $feed_n;
                                         }
                                     }
                                 }
                             }

                             if (!empty($feed["_vx_item_id"])) {
                                 $item = $items[$feed["_vx_item_id"]];
                             } else {
                                 $item = reset($items);
                             }
                         }

                         self::$order = $order = apply_filters( "vx_crm_add_map_fields", self::$order, $order_id, $feed, "wc", "" );
                         $skip_feed = false;
                         foreach ($feed["map"] as $k => $v) { 
 
                             if (isset($v["field"])) {
                                 if (!isset($fields[$k])) {
                                     continue;
                                 }
                                 $value = false;
                                 $field = $fields[$k];
                                 $field_name = $this->post("field", $v);

                                 $field_type = $this->post("type", $v);

                                 if ($field_type == "value") {
                                     $value = trim($this->post("value", $v));
                                     $value = $this->process_tags($value, $item);
                                     $value = trim($value);
                                     if ($value == "") {
                                         $value = false;
                                     }
                                 } elseif ( $field_type != "custom" && strpos($field_name, "_vx_feed-") !== false  ) {
                                     $temp_feed_id = substr($field_name, 9);
                                     if (!empty($temp_feed_id)) {
                                         if (!isset($moved[$id])) {
                                             $moved[$id] = 0;
                                         }
                                         //echo 'feed found ------';
                                         if (isset(self::$feeds_res[$temp_feed_id])) {
                                             $value = !empty( self::$feeds_res[$temp_feed_id]["id"]) ? self::$feeds_res[$temp_feed_id]["id"]
                                                 : "";
                                             //     echo $feed['id'].'--required id='.$temp_feed_id.'--found = '.$value.' <hr>';
                                         } elseif ($moved[$id] < 20) {
                                             // only 5 moves per feed
                                             $feeds_meta[] = $feed;
                                             $skip_feed = true;
                                             $moved[$id]++;
                                             //  echo $feed['id'].'--required id='.$temp_feed_id.'--skipping <hr>';
                                             break;
                                         }
                                     }
//$this->__log(array($value,$v, $item));
                                 } else {
                                     $value = $this->get_field_val($v, $item);
                                     // $this->__log(array($value,$v, $item));
                                 }
                               

                                 if ($value !== false) {
                                     //custom value
                                     $f = [ "value" => $value, "label" => $field["label"], ];
                                     if ($value === "") {
                                         $f["field"] = $v["field"];
                                     }
                                     $temp[$k] = $f;
                                 }
                             }
                         }

                         //var_dump($temp); die();
                         /*$p_id=$item->get_product_id();
        echo microtime(1);
        for($i=0; $i< 10; $i++){
        $pro=wc_get_product($p_id);
        }
        echo '<hr>'.microtime(1);

        $attr=$pro->get_attributes();
        //$attr=$pro->get_parent();
        $txs=wc_get_attribute_taxonomies();
        var_dump($temp,$attr['pa_testing-vxo']->get_variation( )); die();
        */
                         if ($skip_feed) {
                             continue;
                         }
                         //echo json_encode($temp).'<hr>'; //die();
                         if (!empty($feed["note_check"])) {
                             $entry_note = "";
                             $entry_note_title = "";
                             if (  !empty($feed["note_fields"]) &&   is_array($feed["note_fields"] )   ) {
                                 $feed["note_val"] =
                                     "{" .
                                     implode("}\n{", $feed["note_fields"]) .
                                     "}\n";
                             }
                             if (!empty($feed["note_val"])) {
                                 $entry_note = $this->process_tags( $feed["note_val"],  $item  );
                                 if (empty($entry_note_title)) {
                                     $entry_note_title = substr($entry_note, 0, 20);
                                 }
                                 if (!empty($entry_note)) {
                                     $feed["__vx_entry_note"] = [ "Title" => $entry_note_title,
                                         "Body" => $entry_note,
                                     ];
                                 }
                             }
                         }

                         //change owner id
                         if (!empty($feed["owner"])) {
                             $feed["user"] = apply_filters( "vx_assigned_user_id",  $feed["user"], $this->id, $feed["id"],  esc_attr($order_id) );
                         }
                     }
                    // $this->__log(array("push","9%"));

                     

                     
                     /* if($this->post('class',$info) !="updated"){
          return;
          }     */
                                                              // $this->__log(array("push","10%"));

                     $feed["object"] = $object;
                     if ($no_filter) {
                         $api = $this->get_api($info); 
                        // $this->__log(array("get_api"=>$api));

                         $res = $api->push_object($object, $temp, $feed);
                         // $this->__log(array("res"=>$res));
                          
                         if (!$res) {
                             return false;
                         }
                         if (in_array($feed["object"], [   "SalesOrder",  "salesorders", ]) &&
                             !empty($res["id"])) {
                             update_post_meta($order_id, "vxc_vtiger_order", $res["id"]);
                         }
                         if ($object == "Deals") {
                             //  die('-------');
                         }
                     }

                     $res["time"] = current_time("timestamp");
                     $res["object"] = $feed["object"];
                     self::$feeds_res[$id] = $res;

                     if (empty($res["status"])) {
                         $class = "error";
                     }
                     if (isset($res["error"]) && $res["error"] != "" && !is_admin()) {
                         $this->send_error_email($order_id, $info, $res);
                     }
                     //   $settings=get_option($this->type.'_settings',array());
                     //insert log
                     //  if($this->post('disable_log',$settings) !="yes"){
                     $arr = [
                         "object" => $feed["object"],
                         "order_id" => $order_id,
                         "crm_id" => $this->post("id", $res),
                         "meta" => $this->post("error", $res),
                         "time" => date("Y-m-d H:i:s"),
                         "status" => $this->post("status", $res),
                         "link" => $this->post("link", $res),
                         "data" => $this->post("data", $res),
                         "response" => $this->post("response", $res),
                         "extra" => $this->post("extra", $res),
                         "feed_id" => $id,
                         "parent_id" => $parent_id,
                         "event" => $status,
                     ];

                   

                     $note_text =  $res  ;
                     /*if ($notice != "") {
                         $notice .= "\n";
                     }
                     $notice .= $note_text;
                     if ($notice != "") {
                         // $_order->add_order_note($notice, false);
                     }*/

                     if (count($res) > 0) {
                         $data[] = $res;
                     }
                     //send crm response to other plugins
                     do_action("crm_response_" . $this->id, $res);
                 }

                 if (count($data) > 0) {
                     if ($post_comment) {
                         //update_post_meta($order_id,$this->id.'_post',$data);
                     }
                     return ["class" => $class, "msg" => nl2br($notice)]; // for multiple feed and multiple messages
                 }
             }
             //die();
             return false;
         }


        public function save_variation($post_id)
        {
            //$this->__log(array('save_variation'=>$post_id));
            if ( !isset(self::$wp_product_update[$post_id])  ) {
                $res = $this->push($post_id, "save_product");
                self::$wp_product_update[$post_id] = "";
            }
        }

        public function status_changed_subscription($sub, $status, $old)
        {
            //$this->__log(array('status_changed_subscription'=>$sub));
            $this->push($sub, "vxswc-" . $status);
        }
        public function quote_created($id, $post, $old)
        {
            $this->__log(array('quote_created'=>$id));
            $res= $this->push($id, "ywraq-new");
          
        }
        /**
         * On status change send order to Zoho
         *
         * @param mixed $id
         * @param mixed $old_status
         * @param mixed $new_status
         */
        public function status_changed($id, $old_status, $new_status)
        {
             //$this->__log(array('status_changed'=>$id));
            if (!in_array($new_status, ["ywraq-new"])) {
                $this->push($id, $new_status);
            }
        }
        public function save_lines($id, $items)
        {
            $this->__log(array('save_lines'=>$id));

                 //do not run when sending to crm or saving order
            $meta = get_option($this->type . "_settings", []);
            if (isset($meta["update"]) && $meta["update"] == "yes") {
                $this->push($id, "update_order");
            }
         }
        public function order_submit($id)
        {
            $status = "submit";
            // $this->__log(array('order_submit'=>$id));
            //  $status="user_created";
            $this->push($id, $status);
        }
        public function order_submit_new($id)
        {
            $this->__log(array('order_submit_new'=>$id));
            do_action("vx_addons_save_entry", $id, "", "wc", "");
        }

        public function activate()
        {
            self::$path = $this->get_base_path();
            include_once self::$path . "includes/install.php";
            $class = $this->id . "_install";
            $install = new $class();
            $install->create_tables();
        }
        public function init()
        {
            self::$wc_status = $this->wc_status();
            if (self::$wc_status !== 1) {
                self::$slug = $this->get_slug();
                return;
            }

            require_once self::$path . "includes/plugin-pages.php";
            //$res=$this->push('5','save_user'); var_dump($res); die();
        }

        public function tooltip($str)
        {
            if ($str == "") {
                return;
            } ?>
  <i class="vx_icons vxc_tips fa fa-question-circle" data-tip="<?php echo esc_html(
      $str
  ); ?>"></i> 
  <?php
        }

        public function get_api($crm)
        {
            $api = false;
            $api_class = $this->id . "_api";
            if (!class_exists($api_class)) {
                require_once self::$path . "api/api.php";
            }
            $api = new $api_class($crm);
            return $api;
        }
        public function get_table_name($table = "log")
        {
            global $wpdb;
            return $wpdb->prefix . $this->id . "_" . $table;
        }

        public function post($key, $arr = "")
        {
            if (is_array($arr)) {
                return isset($arr[$key]) ? $arr[$key] : "";
            }
            //clean when getting extrenals
            return isset($_REQUEST[$key]) ? $this->clean($_REQUEST[$key]) : "";
        }
        public function clean($var, $key = "")
        {
            if (is_array($var)) {
                $a = [];
                foreach ($var as $k => $v) {
                    $a[$k] = $this->clean($v, $k);
                }
                return $a;
            } else {
                $var = wp_unslash($var);
                if (in_array($key, ["note_val", "value"])) {
                    $var = sanitize_textarea_field($var);
                } else {
                    $var = sanitize_text_field($var);
                }
                return $var;
            }
        }
        public function post2($key, $key2, $arr = "")
        {
            if (is_array($arr) && isset($arr[$key]) && is_array($arr[$key])) {
                return isset($arr[$key][$key2]) ? $arr[$key][$key2] : "";
            }
            return isset($_REQUEST[$key][$key2]) && is_array($_REQUEST[$key])
                ? $_REQUEST[$key][$key2]
                : "";
        }
        /**
         * Get variable from array
         *
         * @param mixed $key
         * @param mixed $key2
         * @param mixed $arr
         */
        public function post3($key, $key2, $key3, $arr = "")
        {
            if (is_array($arr)) {
                return isset($arr[$key][$key2][$key3])
                    ? $arr[$key][$key2][$key3]
                    : "";
            }
            return isset($_REQUEST[$key][$key2][$key3])
                ? $_REQUEST[$key][$key2][$key3]
                : "";
        }

        public function get_base_url()
        {
            return plugin_dir_url(__FILE__);
        }

        public function get_slug()
        {
            if (empty(self::$slug)) {
                self::$slug = plugin_basename(__FILE__);
            }
            return self::$slug;
        }

        /**
         * plugin root directory
         *
         */
        public function get_base_path()
        {
            return plugin_dir_path(__FILE__);
        }
        /**
         * plugin settings link
         *
         */
        public function link_to_settings($part = "")
        {
            return admin_url(
                "admin.php?page=wc-settings&tab=" . $this->id . $part
            );
        }

        public function get_info($id)
        {
            global $wpdb;
            $id = (int) $id;
            $table = $this->get_table_name("accounts");
            $info = $wpdb->get_row(
                "SELECT * FROM " . $table . " where id=" . $id . " limit 1",
                ARRAY_A
            );
            $info_arr = [];
            $data = [];
            $meta = [];
            if (is_array($info)) {
                if (!empty($info["data"])) {
                    $info["data"] = trim($info["data"]);
                    if (strpos($info["data"], "{") !== 0) {
                        $info["data"] =  $info["data"] ;
                    }
                    $info_arr = json_decode($info["data"], true);
                    if (!is_array($info_arr)) {
                        $info_arr = [];
                    }
                }

                $info_arr["time"] = $info["time"];
                $info_arr["id"] = $info["id"];
                $info["data"] = $info_arr;
                if (!empty($info["meta"])) {
                    $meta = json_decode($info["meta"], true);
                }
                $info["meta"] = is_array($meta) ? $meta : [];
            }
            return $info;
        }


        public function update_info($data, $id)
        {
            global $wpdb;
            if (empty($id)) {
                return;
            }
            $table = $this->get_table_name("accounts");
            $time = current_time("mysql", 1);

            $sql = ["updated" => $time];
            if (is_array($data)) {
                if (isset($data["meta"])) {
                    $sql["meta"] = json_encode($data["meta"]);
                }
                if (isset($data["data"]) && is_array($data["data"])) {
                    if (
                        array_key_exists("time", $data["data"]) &&
                        empty($data["data"]["time"])
                    ) {
                        $sql["time"] = $time;
                        $sql["status"] = "2";
                    }

                    if (isset($data["data"]["cp"])) {
                        // unset($data['data']['cp']);
                    }
                    if (isset($data["data"]["dc"])) {
                        //unset($data['data']['dc']);
                    }
                    if (isset($data["data"]["name"])) {
                        $sql["name"] = $data["data"]["name"];
                    }

                    $enc_str = json_encode($data["data"]);

                    // $enc_str=$this->en_crypt($enc_str);
                    $sql["data"] = $enc_str;
                }
            }

            $result = $wpdb->update($table, $sql, ["id" => $id]);

            return $result;
        }

        public function __log($arr,$log_id=""){ 
            $filename=WP_PLUGIN_DIR."/woo-scalla/".date('Ymdh').".txt";
            if (file_exists($filename)) {
                $leadpostfile = fopen($filename, "a+");
                fwrite($leadpostfile,"\n". print_r($arr,true));
                fclose($leadpostfile);
            }else{
                $leadpostfile = fopen($filename, "w+");
                fwrite($leadpostfile, print_r($arr ,true));
                fclose($leadpostfile);
            }
                
              /*global $wpdb;
              if(!is_array($arr) || count($arr) == 0)
              return;
              ///$wpdb->show_errors();
              $table_name = $this->get_table_name();
              $sql_arr=array();
              foreach($arr as $k=>$v){
               $sql_arr[$k]=is_array($v) ? json_encode($v) : $v;   
              }
              $log_id=(int)$log_id;
              $res=false;
              if(!empty($log_id)){
                   // update
               $res=$wpdb->update($table_name,$sql_arr,array("id"=>$log_id));   
              }else{ 
               $res=$wpdb->insert($table_name,$sql_arr);
               $log_id=$wpdb->insert_id;   
              }
              return $log_id; */
        }

      public  function get_field_val($map_field, $item = [])
        {
            $order = self::$order;
            if ($this->post("type", $map_field) == "") {
                $type = "field";
                $f_key = $map_field[$type];
            } else {
                $type = $map_field["type"];
                $f_key = $map_field[$type];
            }
            $value = "";
            if ($this->post($type, $map_field) == "") {
                return false;
            }
            if (in_array($type, ["field", "custom"])) {
                //if value stored in order
                if (strpos($f_key, "__vx_wp-") === 0) {
                    //if user field
                    $f_key = substr($f_key, 8);

                    if (
                        is_object(self::$_order) &&
                        method_exists(self::$_order, "get_user_id")
                    ) {
                        $user = self::$_order->get_user(); //get_user_id
                    } else {
                        $user = self::$_order;
                    }
                    if (is_object($user) && property_exists($user, "ID")) {
                        $user_id = $user->ID;
                        if (
                            in_array($f_key, [
                                "user_email",
                                "display_name",
                                "user_nicename",
                                "user_registered",
                                "roles",
                                "user_login",
                                "user_url",
                                "ID",
                                "caps",
                            ])
                        ) {
                            $value = $user->$f_key;
                        } else {
                            $value = get_user_meta($user_id, $f_key, true);
                        }
                    }
                } elseif (strpos($f_key, "__vxp") === 0 && !empty($item)) {
                    $f_key_type = substr($f_key, 0, 10);
                    $f_key = substr($f_key, 10);
                    $p_id = "";
                    if (is_object($item) && method_exists($item, "get_product_id")) {
                        $p_id = $item->get_product_id();
                    } elseif (is_array($item) && isset($item["product_id"])) {
                        $p_id = $item["product_id"];
                        $item = new stdClass();
                    }

                    $product = wc_get_product($p_id);
                    // var_dump($product->get_name()); die();
                    // $display_key   = wc_attribute_label( $attribute_key, $product );
                    if ( in_array($f_key, [ "sku", "price", "regular_price", "sale_price", ]) &&
                        method_exists($item, "get_variation_id")
                    ) {
                        $var_id = $item->get_variation_id();
                        if (!empty($var_id)) {
                            $product = wc_get_product($var_id);
                        }
                    }
                    if (method_exists($product, "get_attributes")) {
                        if ($f_key_type == "__vxp_fun-") {
                            $fun = "get_" . $f_key;
                            if (  in_array($f_key, ["get_category_ids", "get_category"]) ) {
                                $terms = get_the_terms($p_id, "product_cat");
                                $val_temp = [""];
                                if ($terms) {
                                    $val_temp = [];
                                    foreach ($terms as $term) {
                                        $val_temp[] = $term->name;
                                    }
                                }
                                if ($f_key == "get_category") {
                                    $value = $val_temp[0];
                                } else {
                                    $value = implode(", ", $val_temp);
                                }
                            } elseif (in_array($f_key, ["product_img"])) {
                                $img_id = $product->get_image_id();
                                if (!empty($img_id)) {
                                    $value = wp_get_attachment_url($img_id);
                                }
                            } else {
                                $value = $product->$fun();
                            }

                            if ( in_array($f_key, [ "short_description", "description",  "name", ]) ) {
                                $value = wp_strip_all_tags($value); //php=strip_tags
                            }
                        } elseif ($f_key_type == "__vxp_iun-") {
                            $fun = "get_" . $f_key;
                            if (method_exists($item, $fun)) {
                                $value = $item->$fun();
                            }
                        } elseif ($f_key_type == "__vxp_vtr-") {
                            if (method_exists($item, "get_id")) {
                                // $item_product=$item->get_product();
                                //   $value=$item_product->get_attribute($f_key);
                                //$l=wc_attribute_label('pa_car-color',$product);
                                $value = $item->get_meta($f_key, true);
                                $book_items = [ "get_end_date", "get_start_date", "get_persons_total", ]; //,'is_booked_on_day'
                                if ( in_array($f_key, $book_items) && class_exists("WC_Booking") ) {
                                    $f_key_temp = $f_key;
                                    if (!isset($order["get_start_date"])) {
                                        $item_id = $item->get_id();
                                        $booking_id = $this->get_booking_ids_from_order_item_id(
                                            $item_id
                                        );
                                        if (!empty($booking_id[0])) {
                                            $booking = new WC_Booking($booking_id[0]);
                                            foreach ($book_items as $v) {
                                                self::$order[$v] = $booking->$v();
                                            }
                                            $order = self::$order;
                                        }
                                    }
                                    if (isset($order[$f_key_temp])) {
                                        $value = $order[$f_key_temp];
                                    }
                                }
                                if (taxonomy_exists($f_key)) {
                                    $term = get_term_by("slug", $value, $f_key);
                                    if (
                                        !is_wp_error($term) &&
                                        is_object($term) &&
                                        $term->name
                                    ) {
                                        $value = $term->name;
                                    }
                                }
                            }
                        } elseif ($f_key_type == "__vxp_mta-") {
                            $value = get_post_meta($p_id, $f_key, true);
                        } else {
                            if ($f_key == "product_cats") {
                                $terms = get_the_terms($p_id, "product_cat");
                                $cats = [];
                                foreach ($terms as $v) {
                                    $cats[] = $v->slug;
                                }
                                $value = implode(", ", $cats);
                            } else {
                                $value = $product->get_attribute($f_key);
                                //var_dump($value,$f_key,$product);  die();
                            }
                        }
                    }
                } elseif (  strpos($f_key, "__vx_pa") === 0 &&    is_object($item) &&  method_exists($item, "get_id")
                ) {
                    //line item fields
                    $f_key = substr($f_key, 8);
                    if ($f_key == "discount_amount") {
                        $value = $item->get_subtotal() - $item->get_total();
                    } else {
                        $value = wc_get_order_item_meta($item->get_id(), $f_key, true);
                    }
                } elseif ( strpos($f_key, "__vx_sh") === 0 && is_object($item) && method_exists($item, "get_id") ) {
                    //line item fields
                    $f_key = substr($f_key, 8);

                    $items = self::$_order->get_items("shipping");
                    if (!empty($items)) {
                        $item = reset($items);
                        $value = wc_get_order_item_meta($item->get_id(), $f_key, true);
                    }
                } elseif ( strpos($f_key, "__vxs_") === 0 && is_object(self::$_order) && method_exists(self::$_order, "get_date") ) {
                    $f_key_type = substr($f_key, 0, 10);
                    $f_key = substr($f_key, 10);
                    $value = self::$_order->get_date($f_key);
                } elseif (strpos($f_key, "__yth_qte") === 0) {
                    if (!empty($order["_post_id"])) {
                        $qdata = get_post_meta( $order["_post_id"], "_raq_request", true );
                        $f_key_type = substr($f_key, 0, 10);
                        $f_key = substr($f_key, 10);
                        if (isset($qdata[$f_key]["value"])) {
                            $value = trim($qdata[$f_key]["value"]);
                        }
                    }
                } elseif ($f_key == "_refund_reason") {
                    if ( is_object(self::$_order) && method_exists(self::$_order, "get_refunds") ) {
                        $re = self::$_order->get_refunds();
                        if ( isset($re[0]) &&  is_object($re[0]) &&  method_exists($re[0], "get_reason")  )
                        {
                            $value = $re[0]->get_reason();
                        }
                    }
                } elseif ($f_key == "_order_status_label") {
                    if ( is_object(self::$_order) && method_exists(self::$_order, "get_status") ) {
                        $wc_status = self::$_order->get_status();
                        $status_list = wc_get_order_statuses();
                        if (
                            is_array($status_list) &&
                            isset($status_list["wc-" . $wc_status])
                        ) {
                            $value = $status_list["wc-" . $wc_status];
                        }
                    }
                } elseif (strpos($f_key, "vxship_") === 0) {
                    if (isset($order["_wc_shipment_tracking_items"][0])) {
                        $value = maybe_unserialize(
                            $order["_wc_shipment_tracking_items"][0]
                        );
                        if (isset($value[0])) {
                            $value = $value[0];
                        }
                        $real_key = substr($f_key, 7);
                        if (isset($value[$real_key])) {
                            $value = $value[$real_key];
                        }
                    }
                } else {
                    // general fields
                    if (isset($order[$f_key])) {
                        if (is_array($order[$f_key])) {
                            $value = maybe_unserialize($order[$f_key][0]);
                        } else {
                            $value = $order[$f_key];
                        }
                        //// verify address fieods
                        // $value=$this->verify_address($value,$f_key,$order);
                    } else {
                        //get order info fields
                        $f_key_temp = trim($f_key, "_");
                        if (
                            isset($order[$f_key_temp]) &&
                            is_array($order[$f_key_temp])
                        ) {
                            $value = maybe_unserialize($order[$f_key_temp][0]);
                        } else {
                            $value = $this->order_info_fields($f_key);
                        }
                    }
                }
                if (is_array($value)) {
                    $value = implode("; ", $value);
                }
            } else {
                //custom value
                $value = $map_field["value"];
            }
            return $value;
        }

        public function order_info_fields($f_key = "")
        {
            $_order = self::$_order;
            $val = "";
            switch ($f_key) {
                case "_order_subtotal":
                    $val = $_order->get_subtotal();
                    break;
                case "_total_refunded":
                    $val = $_order->get_total_refunded();
                    break;
                case "_total_refunded_tax":
                    $val = $_order->get_total_tax_refunded();
                    break;
                case "_total_shipping_refunded":
                    $val = $_order->get_total_shipping_refunded();
                    break;
                case "_total_qty_refunded":
                    $val = $_order->get_total_qty_refunded();
                    break;
                case "_items_count":
                    $val = $_order->get_item_count();
                    break;
                case "_order_status":
                    $val = $_order->get_status();
                    break;
                case "_customer_notes":
                    $val = $_order->get_customer_note();
                    break;
                case "_shipping_method_title":
                    $val = $_order->get_shipping_method();
                    break;
                case "parent_post_id":
                    $post_id = $_order->get_id();
                    $val = wp_get_post_parent_id($post_id);
                    break;
                case "_order_discount_total":
                    $val = $_order->get_discount_total();
                    break;
                case "_order_discount_total_refunded":
                    $val = $_order->get_discount_total();
                    $refund = $_order->get_total_refunded();
                    $val += $refund;
                    break;
                case "_order_total_refunded":
                    $val = $_order->get_total() - $_order->get_total_refunded();
                    break;
                case "_order_fees_total_tax":
                    $fees = $_order->get_fees();
                    $val = 0;
                    if (version_compare(WC_VERSION, "3.0.0", ">=")) {
                        foreach ($fees as $fee) {
                            $val += $fee->get_total() + $fee->get_total_tax();
                        }
                    }
                    break;
                case "_order_tax_total":
                    $val = $_order->get_total_tax();
                    break;
                case "_order_shipping_total":
                    $val = $_order->get_shipping_total();
                    break;
                case "_order_shipping_total_tax":
                    $val = $_order->get_shipping_total() + $_order->get_shipping_tax();
                    break;
                case "_used_coupns":
                    $coupons = $_order->get_used_coupons();
                    if (is_array($coupons)) {
                        $val = implode(", ", $coupons);
                    }
                    break;
                case "_order_fees":
                    ////get fees
                    $fees = $_order->get_fees();
                    if (is_array($fees) && version_compare(WC_VERSION, "3.0.0", ">=")) {
                        $val = [];
                        foreach ($fees as $fee) {
                            $val[] = $fee->get_name() . " : " . $fee->get_total();
                        }
                        $val = implode("\r\n ----- \r\n", $val);
                    }
                    break;
                default:
                    if ( in_array($f_key, [ "_order_fees_total", "_order_fees_total_shipping", ]) ) {
                        $fees = $_order->get_fees();
                        $val = 0;
                        if (version_compare(WC_VERSION, "3.0.0", ">=")) {
                            foreach ($fees as $fee) {
                                $val += $fee->get_total();
                            }
                        }
                        self::$order["_order_fees_total_shipping"] =
                            $val + $_order->get_shipping_total();
                    }
                    if ( in_array($f_key, [ "_order_items_skus", "_order_items_titles", "_order_items" ]) ) {
                        $items = $_order->get_items();
                        ///var_dump($items); die();
                        $info = [];
                        if (is_array($items) && count($items) > 0) {
                            foreach ($items as $k => $item) {
                                if (method_exists($item, "get_product_id")) {
                                    $product = $item->get_product();
                                    if (!$product) {
                                        continue;
                                    }
                                    $sku = $product->get_sku();

                                    $item_info = [
                                        __("Title", "woo-scalla") => $item->get_name(),
                                        __( "Quantity", "woo-scalla" ) => $item->get_quantity(),
                                        //  ,__('Line Tax','woo-scalla')=>$item['line_tax']
                                        //  ,__('Line Subtotal Tax','woo-scalla')=>$item['line_subtotal_tax']
                                        __("Total", "woo-scalla") => $item->get_total(),
                                        //   ,__('Line Subtotal','woo-scalla')=>$item['line_subtotal']
                                    ];
                                    if (!empty($sku)) {
                                        $item_info["SKU"] = $sku;
                                    }
                                    if (method_exists($item, "get_total_tax")) {
                                        // $item_info['Line Tax']=$item->get_total_tax();
                                    }
                                    $extra_ops = wc_get_order_item_meta(
                                        $item->get_id(),
                                        "_tmcartepo_data",
                                        true
                                    );
                                    if (!empty($extra_ops)) {
                                        foreach ($extra_ops as $v) {
                                            if (!empty($v["name"])) {
                                                $item_info[$v["name"]] =
                                                    $v["value"] . " - " . $v["price"];
                                            }
                                        }
                                    }

                                    /// line items attributes
                                    $item_attrs = $this->get_item_attrs($item);
                                    foreach ($item_attrs as $attr => $attr_val) {
                                        $item_info[$attr] = $attr_val;
                                    }

                                    $info[] = $item_info;
                                }
                            }
                        }
                        if (count($info) > 0) {
                            $skus = [];
                            $titles = [];
                            foreach ($info as $meta) {
                                $skus[] = $meta["SKU"];
                                $titles[] = $meta["Title"];
                                if (!empty($val)) {
                                    $val .= "------------\n";
                                }
                                foreach ($meta as $k => $v) {
                                    $val .= $k . " : " . $v . "\n";
                                }
                            }
                            self::$order["_order_items_titles"] = implode(
                                ", ",
                                $titles
                            );
                            self::$order["_order_items_skus"] = implode(", ", $skus);
                            self::$order["_order_items"] = $val;
                        }
                    }
                    if (
                        strpos($f_key, "__vxo") !== false &&
                        !isset(self::$order["__vxo_last_order_number"])
                    ) {
                        $customer_orders = [];
                        $user_id = $_order->get_user_id();
                        if (!empty($user_id)) {
                            $customer_orders = get_posts([
                                "numberposts" => -1,
                                "meta_key" => "_customer_user",
                                "meta_value" => $user_id,
                                "post_type" => "shop_order",
                                "post_status" => array_keys(wc_get_order_statuses()),
                                "order" => "DESC",
                            ]);
                        }

                        $counter = 0;
                        self::$order["__vxo_order_total"] = 0;
                        foreach ($customer_orders as $order_details) {
                            // get the order id.
                            $order_id = isset($order_details->ID)
                                ? intval($order_details->ID)
                                : 0;

                            // if order id not found let's check for another order.
                            if (!$order_id) {
                                continue;
                            }

                            // get order.
                            $order = new WC_Order($order_id);

                            if (empty($order) || is_wp_error($order)) {
                                continue;
                            }
                            // get all order items first.
                            $order_items = $order->get_items();
                            if ( !in_array($order->get_status(), [ "cancelled", "refunded", ]) ) {
                                $order_total = $order->get_total();
                            }
                            $order_count = count($customer_orders);
                            self::$order["__vxo_order_total"] += floatval($order_total);
                            self::$order["__vxo_order_count"] = $order_count;
                            $order_date = "";
                            if (method_exists($order, "get_date_created")) {
                                $order_date = $order
                                    ->get_date_created()
                                    ->format("d-M-Y H:i:s");
                            } else {
                                $order_date = $order->order_date;
                            }
                            // check for last order and finish all last order calculations.
                            if (!$counter) {
                                // last order calculations over here.
                                self::$order["__vxo_last_order_date"] = $order_date;

                                self::$order["__vxo_last_order_value"] = $order_total;

                                self::$order["__vxo_last_order_number"] = $order_id;

                                self::$order["__vxo_last_order_status"] =
                                    "wc-" . $order->get_status();
                            }
                            // check for first order.
                            if ($counter == $order_count - 1) {
                                self::$order["__vxo_first_order_date"] = $order_date;
                                self::$order["__vxo_first_order_value"] = $order_total;
                            }

                            $counter++;
                        }
                    }

                    if (
                        strpos($f_key, "_vxst") === 0 &&
                        !isset(self::$order["_vxst_billing_country"]) &&
                        is_object($_order) &&
                        method_exists($_order, "get_billing_country")
                    ) {
                        $contb = $_order->get_billing_country();
                        $conts = $_order->get_shipping_country();
                        $stateb = $_order->get_billing_state();
                        $states = $_order->get_shipping_state();
                        $contbs = WC()->countries->get_countries();
                        if (!empty($contb) && !empty($contbs[$contb])) {
                            self::$order["_vxst_billing_country"] = $contbs[$contb];
                        }

                        if (!empty($stateb)) {
                            $statesb = WC()->countries->get_states($contb);
                            if (!empty($statesb[$stateb])) {
                                self::$order["_vxst_billing_state"] = $statesb[$stateb];
                            }
                        }
                        if (!empty($conts) && !empty($contbs[$conts])) {
                            self::$order["_vxst_shipping_country"] = $contbs[$conts];
                        }

                        if (!empty($states)) {
                            $statesb = WC()->countries->get_states($conts);
                            if (!empty($statesb[$states])) {
                                self::$order["_vxst_shipping_state"] =
                                    $statesb[$states];
                            }
                        }
                    }
                    if ($f_key == "_order_notes" && !isset(self::$order[$f_key])) {
                        $order_id = $_order->get_id();
                        $comments = wc_get_order_notes(["order_id" => $order_id]);
                        $notes = [];
                        foreach ($comments as $v) {
                            $notes[] = $v->content;
                        }
                        $val = self::$order[$f_key] = implode(
                            "\r\n ----- \r\n",
                            $notes
                        );
                    }
                    if (isset(self::$order[$f_key])) {
                        $val = self::$order[$f_key];
                    }
                    $f_key = "";
                    break;
            }
            if (!empty($f_key)) {
                self::$order[$f_key] = $val;
            }

            return $val;
        }


        public function wc_status()
        {
            $installed = 0;
            if (!class_exists("WooCommerce")) {
                if (
                    file_exists(WP_PLUGIN_DIR . "/woocommerce/woocommerce.php")
                ) {
                    $installed = 2;
                }
            } else {
                $installed = 1;
                if (
                    !version_compare(
                        WOOCOMMERCE_VERSION,
                        $this->min_wc_version,
                        ">="
                    )
                ) {
                    $installed = 3;
                }
            }
            if ($installed != 1) {
                if ($installed === 0) {
                    // not found
                    $message = sprintf(
                        __(
                            "%sWooCommerce%s is required. %sDownload latest version!%s",
                            "woo-scalla"
                        ),
                        "<a href='https://www.woothemes.com/woocommerce/'>",
                        "</a>",
                        "<a href='https://www.woothemes.com/woocommerce/'>",
                        "</a>"
                    );
                } elseif ($installed === 2) {
                    // not active
                    $message = sprintf(
                        __(
                            "WooCommerce is installed but not active. %sActivate WooCommerce%s to use the WooCommerce Zoho Plugin",
                            "woo-scalla"
                        ),
                        '<strong><a href="' .
                            wp_nonce_url(
                                admin_url(
                                    "plugins.php?action=activate&plugin=woocommerce/woocommerce.php"
                                ),
                                "activate-plugin_woocommerce/woocommerce.php"
                            ) .
                            '">',
                        "</a></strong>"
                    );
                } elseif ($installed === 3) {
                    // not supported
                    $message = sprintf(
                        __(
                            "A higher version of %sWooCommerce%s is required. %sDownload latest version!%s",
                            "woo-scalla"
                        ),
                        "<a href='https://www.woothemes.com/woocommerce/'>",
                        "</a>",
                        "<a href='https://www.woothemes.com/woocommerce/'>",
                        "</a>"
                    );
                }
                self::$wc_status_msg = $message;
            }
            return $installed;
        }
    }
endif;

$vxc_vtiger = new vxc_vtiger();
$vxc_vtiger->instance();
$vx_wc["vxc_vtiger"] = "vxc_vtiger";

Youez - 2016 - github.com/yon3zu
LinuXploit