global $wpdb;
 if (isset($_POST['offset']) && !empty($_POST['offset'])) {
     //sleep(10);
     $offset = $_POST['offset'] - 1;
     // start from 0
     $query_with_limit = "SELECT ID,post_status,post_title,post_content,post_type FROM `" . $wpdb->prefix . "posts`  WHERE post_type = 'product' AND post_status!='auto-draft' ORDER BY ID ASC LIMIT " . $offset . ",1";
     $product_details = mysql_query($query_with_limit) or die(mysql_error());
     $product_wc = mysql_fetch_assoc($product_details);
     if ($product_wc['post_status'] != 'trash') {
         $taxsetup = false;
         $product = array();
         $post_detail = get_post_meta($product_wc['ID']);
         if (@empty($post_detail['_sku'][0])) {
             $post_detail['_sku'][0] = 'sku_' . $product_wc['ID'];
         }
         $post_detail['_sku'][0] = linksync_removespaces_sku($post_detail['_sku'][0]);
         update_post_meta($product_wc['ID'], '_sku', $post_detail['_sku'][0]);
         $product['sku'] = html_entity_decode($post_detail['_sku'][0]);
         $product['active'] = isset($product_wc['post_status']) && $product_wc['post_status'] == 'publish' ? 1 : 0;
         if (get_option('ps_price') == 'on') {
             if (isset($post_detail['_tax_status'][0]) && $post_detail['_tax_status'][0] == 'taxable') {
                 $taxname = empty($post_detail['_tax_class'][0]) ? 'standard-tax' : $post_detail['_tax_class'][0];
                 $response_taxes = linksyn_get_tax_details_syncall_QBO($taxname);
                 if ($response_taxes['result'] == 'success') {
                     $product['tax_name'] = html_entity_decode($response_taxes['data']['tax_name']);
                     $product['tax_rate'] = $response_taxes['data']['tax_rate'];
                     $taxsetup = true;
                 }
             }
             if (get_option('excluding_tax') == 'on') {
                 if ($taxsetup) {
         $product['brands'] = $brands;
     }
     //To free an array to use futher
     unset($brands);
 }
 $variants_data = mysql_query("SELECT ID,post_title FROM `" . $wpdb->prefix . "posts` WHERE post_type = 'product_variation' AND post_parent ='" . $product_wc['ID'] . "' AND post_status!='auto-draft'");
 //  $variants_data = mysql_query("SELECT ID,post_title FROM `" . $wpdb->prefix . "posts` WHERE post_type = 'product_variation' AND post_parent ='" . $product_wc['ID'] . "'");
 if (mysql_num_rows($variants_data) != 0) {
     $total_var_product = 0;
     while ($variant_data = mysql_fetch_assoc($variants_data)) {
         $option = array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten');
         $variants_detail = get_post_meta($variant_data['ID']);
         if (@empty($variants_detail['_sku'][0])) {
             $variants_detail['_sku'][0] = 'sku_' . $variant_data['ID'];
         }
         $variants_detail['_sku'][0] = linksync_removespaces_sku($variants_detail['_sku'][0]);
         update_post_meta($variant_data['ID'], '_sku', $variants_detail['_sku'][0]);
         $variant['sku'] = html_entity_decode($variants_detail['_sku'][0]);
         //SKU(unique Key)
         #Name/Title Check
         if (get_option('ps_name_title') == 'on') {
             $variant['name'] = html_entity_decode($variant_data['post_title']);
         }
         #quantity
         if (@$variants_detail['_stock_status'][0] == 'instock') {
             $variant['quantity'] = @$variants_detail['_stock'][0];
         }
         // Price with Tax
         if (get_option('ps_price') == 'on') {
             if (isset($variants_detail['_tax_status'][0]) && $variants_detail['_tax_status'][0] == 'taxable') {
                 # Product with TAX