Plugin Directory

Changeset 3006736


Ignore:
Timestamp:
12/07/2023 12:06:05 PM (2 years ago)
Author:
eshipper
Message:

v2.16.4

Location:
eshipper-commerce
Files:
2 deleted
9 edited
25 copied

Legend:

Unmodified
Added
Removed
  • eshipper-commerce/tags/2.16.4/framework/db.php

    r2963096 r3006736  
    44 eshipper_db.php
    55
    6  
     6
    77 */
    88abstract class eshipper_db
    99{
    1010    public $collate;
    11     public function setup() {
     11    public function setup()
     12    {
    1213        // Create sql tables as needed.
    1314        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    1415        $this->get_collate();
    15         // Future development
    16         // if ($this->get_resource('shipments_implemented')){
    17         //     $this->sql_shipments();
    18         //     $this->sql_lists();
    19         //     $this->sql_services();
    20         // }
    21         // Done.
    2216        update_option('eshipper_version', ESHIPPER_VERSION);
    2317    }
    2418
    25     public function updateDBForVersion2_15()
     19    public function get_collate()
    2620    {
    27         if (version_compare(phpversion(), '8.0', '>=')) {
    28             require_once(ESHIPPER_PLUGIN_PATH . '/plugin/PluginHealthHelper.php');
    29 
    30             PluginHealthHelper::createEshipperPluginHealthTable();
    31         }
    32 
    33         // Shipping address table structure was updated to change 'phone_no' datatype to varchar from int
    34         pluginLifeCycle::createEshipperShippingAddressTable();
    35 
    36         update_option('eshipper_version', ESHIPPER_VERSION_LATEST);
    37     }
    38 
    39     public function get_collate() {
    4021        global $wpdb;
    41         if ($wpdb->has_cap( 'utf8mb4_520' )){
     22        if ($wpdb->has_cap('utf8mb4_520')) {
    4223            $this->collate = 'DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci';
    43         } elseif ($wpdb->has_cap( 'utf8mb4' )){
     24        } elseif ($wpdb->has_cap('utf8mb4')) {
    4425            $this->collate = 'DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci';
    4526        } else {
     
    5132
    5233    /*
    53     * Return resources
    54     */
    55     abstract function get_resource($id);
     34    * Return resources
     35    */
     36    abstract public function get_resource($id);
    5637
    5738    /*
    5839     * Date format
    5940    */
    60     public function db_datetime($datestring){
    61         if (!empty($datestring)){
     41    public function db_datetime($datestring)
     42    {
     43        if (!empty($datestring)) {
    6244            // Converts to mysql date string format
    6345            return (new DateTime($datestring))->format('Y-m-d H:i:s');
     
    6648        return '';
    6749    }
    68 
    6950}
  • eshipper-commerce/tags/2.16.4/framework/plugin.php

    r2966127 r3006736  
    4343
    4444        // Database integration
    45         add_action('init', [&$this, 'eshipper_db']);
     45//        add_action('init', [&$this, 'eshipper_db']);
    4646
    4747        // Wire up product shipping options
     
    194194            wp_enqueue_script('eshipper-require-postalcode', plugins_url('lib/require-postalcode.js', ESHIPPER_PLUGIN_FILE), ['jquery'], ESHIPPER_VERSION, true);
    195195            echo '<div id="calc_shipping_postcode_required" class="hidden woocommerce-info" style="display:none">' . __(
    196                     'Zip / Postal Code is required to calculate shipping',
    197                     'woocommerce-eshipper'
    198                 ) . '</div>';
     196                'Zip / Postal Code is required to calculate shipping',
     197                'woocommerce-eshipper'
     198            ) . '</div>';
    199199        }
    200200
     
    259259
    260260        // If the plugin is deactivated, activate it again
    261         // TODO: Check if this works
    262261        require_once(ABSPATH . 'wp-admin/includes/plugin.php');
    263262        if (!is_plugin_active(plugin_basename(ESHIPPER_PLUGIN_FILE))) {
     
    265264        }
    266265
    267         /**
    268          * Updates required for Version >= 2.15.0 & < 2.16.0
    269          */
    270 
    271         // DB upgrade for version 2.15.1
    272         $version = get_option('eshipper_version', '1.0');
    273         if (version_compare($version, ESHIPPER_VERSION_DB_UPDATE, '<')) {
    274             // Get required files for db upgrade
    275             if (!class_exists('woocommerce_eshipper_db')) {
    276                 require_once(ESHIPPER_PLUGIN_PATH . '/framework/db.php');
    277                 require_once(ESHIPPER_PLUGIN_PATH . '/models/woocommerce_eshipper_db.php');
    278             }
    279             // Setup / Run Update.
    280             (new woocommerce_eshipper_db())->updateDBForVersion2_15();
    281         }
     266        // Apply DB updates
     267        pluginLifeCycle::updateDB();
     268        update_option('eshipper_version', ESHIPPER_VERSION);
    282269    }
    283270
     
    332319    {
    333320        return "<p>New feature: <b>Shipping Calculator</b><br>
    334 <ul><li>You can now test Live Shipping Rates without going through the checkout process!</li>
    335 <li>UI/UX Upgrades </li>
    336 <li>Major Bug Fixes. </li>
     321<ul><li>Bug fix for 'Update Database' error in Plugin Health page</li>
    337322</ul></p>";
    338323    }
    339324
    340325
     326    /**
     327     * @deprecated
     328     * @return void
     329     */
    341330    public function eshipper_db()
    342331    {
  • eshipper-commerce/tags/2.16.4/framework/shippingmethod.php

    r2984482 r3006736  
    406406                    <?php _e('Plugin Health', 'woocommerce-eshipper') ?>
    407407                </a>
    408                 <!--            <a href="#eshipper_boxing_manager" class="nav-tab" id="eshipper_services_tab">-->
    409                 <?php //_e('Boxing Manager', 'woocommerce-eshipper')
    410                 ?><!--</a>-->
    411                 <!--<a href="#eshipper_flatrates" class="nav-tab" id="eshipper_flatrates_tab"><?php /*_e('Lettermail/Flat Rates', 'woocommerce-eshipper') */ ?></a>-->
    412                 <!--                <a href="#eshipper_shipments" class="nav-tab --><?php //echo $this->get_resource('display_shipmentstab');
    413                 ?><!--"-->
    414                 <!--                   id="eshipper_shipments_tab">--><?php //_e('Shipment Labels', 'woocommerce-eshipper')
    415                 ?><!--</a>-->
    416                 <!--<a href="#eshipper_tracking" class="nav-tab" id="eshipper_tracking_tab"><?php /*_e('Tracking', 'woocommerce-eshipper') */ ?></a>
    417             <a href="#eshipper_update" class="nav-tab" id="eshipper_update_tab"><?php /*_e('Updates', 'woocommerce-eshipper') */ ?></a>-->
    418408            </div>
    419409
     
    12771267                </div>
    12781268            </div>
    1279 
    1280             <div class="eshipper_panel eshipper_hidden" id="eshipper_boxing_manager">
    1281                 <h3><?php echo $this->get_resource('method_title') . ' ';
    1282         _e('Boxing Manager', 'woocommerce-eshipper') ?></h3>
    1283                 <table class="es_form-table">
    1284                     <tr valign="top"
    1285                         class="woocommerce-eshipper-development-api <?php if ($this->options->mode != 'dev' && $this->options->shipment_mode != 'dev') {
    1286                             echo 'hidden';
    1287                         } ?>">
    1288                         <th><?php _e('Box Dimensions', 'woocommerce-eshipper') ?></th>
    1289                         <td>
    1290                             <br/><br/>
    1291                             <table class="es_form-table" id="main_table">
    1292                                 <thead>
    1293                                 <tr>
    1294                                     <td></td>
    1295                                     <td></td>
    1296                                     <td>Name</td>
    1297                                     <td>Length(in)</td>
    1298                                     <td>Width(in)</td>
    1299                                     <td>Height(in)</td>
    1300                                     <td>Box Weight(lbs)</td>
    1301                                     <td>Max Weight(lbs)</td>
    1302                                 </tr>
    1303                                 </thead>
    1304 
    1305                                 <?php
    1306                                 global $wpdb;
    1307         $box_master_table = $wpdb->prefix . "eshipper_boxing_services_master";
    1308         $number_of_boxes = $wpdb->get_results("SELECT count(*) as count FROM $box_master_table");
    1309         ?>
    1310                                 <tbody id="boxing_manager_boxes">
    1311                                 <tr id="row_0">
    1312                                     <td></td>
    1313                                     <td><input type="checkbox" id="checkbox_box_0"></td>
    1314                                     <td><input type="text" id="box_0_name" style="min-width:50px;" placeholder="Box Name"></td>
    1315                                     <td><input type="text" id="box_0_length" style="min-width:20px;" placeholder="Length"></td>
    1316                                     <td><input type="text" id="box_0_width" style="min-width:20px;" placeholder="Width"></td>
    1317                                     <td><input type="text" id="box_0_height" style="min-width:20px;" placeholder="Height"></td>
    1318                                     <td><input type="text" id="box_0_box_weight" style="min-width:20px;" placeholder="Box Weight"></td>
    1319                                     <td><input type="text" id="box_0_max_weight" style="min-width:20px;" placeholder="Max Weight"></td>
    1320                                 </tr>
    1321                                 </tbody>
    1322                                 <tfoot>
    1323                                 <tr>
    1324                                     <td></td>
    1325                                     <td></td>
    1326                                     <td>
    1327                                         <button type="button" id="add_box_btn">Add Box</button>
    1328                                     </td>
    1329                                     <td>
    1330                                         <button type="button" id="remove_box_btn">Remove Selected Box/Boxes</button>
    1331                                     </td>
    1332                                     <!--<td><button type="button" id="remove_box_btn">Remove Box</button></td>-->
    1333                                 </tr>
    1334                                 </tfoot>
    1335                             </table>
    1336                             <br/>
    1337                             <script type="text/javascript">
    1338                                 jQuery(document).ready(function () {
    1339 
    1340                                     var get_boxing_form_data = {
    1341                                         "boxing_flag": "fetch"
    1342                                     }
    1343                                     jQuery.ajax({
    1344                                         type: "post",
    1345                                         dataType: "json",
    1346                                         url: ajaxurl,
    1347                                         data: {
    1348                                             action: "boxing_insert",
    1349                                             formdata: get_boxing_form_data,
    1350                                         },
    1351                                         success: function (response) {
    1352                                             var number_of_boxes = (response.boxing_data.length);
    1353                                             if (number_of_boxes > 0) {
    1354                                                 jQuery("#boxing_manager_boxes").html("");
    1355                                             }
    1356 
    1357                                             for (var i = 0; i < number_of_boxes; i++) {
    1358                                                 jQuery("#boxing_manager_boxes").append("" +
    1359                                                     "<tr id='row_" + i + "'>" +
    1360                                                     "<td></td>" +
    1361                                                     "<td><input type='checkbox' id='checkbox_box_" + i + "'></td>" +
    1362                                                     "<td><input type='text'  id='box_" + i + "_name' style='min-width:20px;' placeholder='Box Name' value='" + response.boxing_data[i].box_name + "'></td>" +
    1363                                                     "<td><input type='text'  id='box_" + i + "_length' style='min-width:20px;' placeholder='Length' value='" + response.boxing_data[i].box_length + "'></td>" +
    1364                                                     "<td><input type='text'  id='box_" + i + "_width' style='min-width:20px;' placeholder='Width' value='" + response.boxing_data[i].box_width + "'></td>" +
    1365                                                     "<td><input type='text'  id='box_" + i + "_height' style='min-width:20px;' placeholder='Height' value='" + response.boxing_data[i].box_height + "'></td>" +
    1366                                                     "<td><input type='text'  id='box_" + i + "_box_weight' style='min-width:20px;' placeholder='Box Weight' value='" + response.boxing_data[i].box_weight + "'></td>" +
    1367                                                     "<td><input type='text'  id='box_" + i + "_max_weight' style='min-width:20px;' placeholder='Max Weight' value='" + response.boxing_data[i].max_box_weight + "'></td>" +
    1368                                                     "</tr>"
    1369                                                 );
    1370                                             }
    1371                                         }
    1372                                     });
    1373 
    1374 
    1375                                     //Onclick of remove box button
    1376                                     jQuery("body").on('click', '#remove_box_btn', function (event) {
    1377                                         event.preventDefault();
    1378                                         var check_flag = [];
    1379                                         var check_ids = [];  //array to store the id of the checkboxes that have been checked for removal
    1380                                         var finalCheckArray = {};
    1381                                         for (var i = 0; i < 10; i++) {
    1382                                             check_flag[i] = jQuery("#checkbox_box_" + i).is(":checked");
    1383                                             if (check_flag[i] == true) {
    1384                                                 check_ids.push(i);
    1385                                             }
    1386                                         }
    1387                                         for (var remove_counter = 0; remove_counter < check_ids.length; remove_counter++) {
    1388                                             jQuery("#row_" + check_ids[remove_counter]).remove();
    1389                                         }
    1390 
    1391                                     });
    1392 
    1393 
    1394                                     //On click of add button in boxing manager settings
    1395                                     jQuery("body").on('click', '#add_box_btn', function (event) {
    1396                                         event.preventDefault();
    1397                                         var id = (jQuery('#main_table tbody tr:last').index());
    1398                                         id = id + 1;
    1399                                         jQuery("#main_table").append("" +
    1400                                             "<tr id='row_" + id + "'>" +
    1401                                             "<td></td>" +
    1402                                             "<td><input type='checkbox' id='checkbox_box_" + id + "'></td>" +
    1403                                             "<td><input type='text'  id='box_" + id + "_name' style='min-width:50px;' placeholder='Box Name'></td>" +
    1404                                             "<td><input type='text'  id='box_" + id + "_length' style='min-width:20px;' placeholder='Length'></td>" +
    1405                                             "<td><input type='text'  id='box_" + id + "_width' style='min-width:20px;' placeholder='Width'></td>" +
    1406                                             "<td><input type='text'  id='box_" + id + "_height' style='min-width:20px;' placeholder='Height'></td>" +
    1407                                             "<td><input type='text'  id='box_" + id + "_box_weight' style='min-width:20px;' placeholder='Box Weight'></td>" +
    1408                                             "<td><input type='text'  id='box_" + id + "_max_weight' style='min-width:20px;' placeholder='Max Weight'></td>" +
    1409                                             "</td>" +
    1410                                             "</tr>"
    1411                                         );
    1412                                     });
    1413 
    1414                                     //Onclick of save button in boxing manager settings
    1415                                     jQuery("body").on('click', '#save_boxing_options', function (event) {
    1416                                         event.preventDefault();
    1417                                         var finalArray = {};
    1418                                         for (var i = 0; i < 10; i++) {
    1419                                             var j = i;
    1420                                             var finalSubArray = {};
    1421                                             finalSubArray.name = jQuery("#box_" + j + "_name").val();
    1422                                             finalSubArray.box_length = jQuery("#box_" + j + "_length").val();
    1423                                             finalSubArray.box_width = jQuery("#box_" + j + "_width").val();
    1424                                             finalSubArray.box_height = jQuery("#box_" + j + "_height").val();
    1425                                             finalSubArray.box_weight = jQuery("#box_" + j + "_box_weight").val();
    1426                                             finalSubArray.box_max_weight = jQuery("#box_" + j + "_max_weight").val();
    1427                                             finalArray[i] = finalSubArray;
    1428                                         }
    1429 
    1430                                         jQuery.ajax({
    1431                                             type: "post",
    1432                                             dataType: "json",
    1433                                             url: ajaxurl,
    1434                                             data: {
    1435                                                 action: "boxing_insert",
    1436                                                 formdata: finalArray,
    1437                                             },
    1438                                             success: function (response) {
    1439                                                 if (response.statusCode == 200) {
    1440                                                     jQuery("#boxing_save_message_display").text(response.msg);
    1441                                                     jQuery("#boxing_save_message_display").css('color', 'green');
    1442                                                 }
    1443 
    1444                                             }
    1445                                         });
    1446                                     });
    1447                                 });
    1448                             </script>
    1449 
    1450                             <button type="submit" name="save_boxing_options" value="save_boxing_options" id="save_boxing_options">Save Boxing
    1451                                 Information
    1452                             </button>
    1453                             <br/><br/>
    1454                             <div id="boxing_save_message_display"></div>
    1455                         </td>
    1456                     </tr>
    1457                 </table>
    1458             </div>
    14591269        </div>
    14601270
  • eshipper-commerce/tags/2.16.4/plugin/PluginHealthHelper.php

    r2984482 r3006736  
    6565        $create_plugin_health_table = " CREATE TABLE $table($columns
    6666            created_time timestamp DEFAULT CURRENT_TIMESTAMP,
    67             updated_time timestamp DEFAULT NULL
     67            updated_time timestamp DEFAULT CURRENT_TIMESTAMP
    6868        )";
    6969
    7070        require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    71         dbDelta($create_plugin_health_table);
     71        $queryResult = dbDelta($create_plugin_health_table);
    7272
    7373        // Check if table exists at this point before proceeding.
     
    7575        global $wpdb;
    7676        if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    77             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
     77            wc_get_logger()->error("Could not create table - $table \n Query Result - \n" . var_export($queryResult, true), ['source' => 'eshipper']);
    7878            return false;
    7979        }
  • eshipper-commerce/tags/2.16.4/plugin/pluginLifeCycle.php

    r2963096 r3006736  
    2323
    2424        // Create all required tables for the plugin
     25        self::updateDB();
     26    }
     27
     28    /**
     29     * Create/update all required tables for the plugin
     30     * @return void
     31     */
     32    public static function updateDB()
     33    {
     34        // All methods called here use dbDelta to create/update the tables
     35        // and hence always contain the latest structure of the table
    2536        pluginLifeCycle::createEshipperAccessTokensTable();
    2637        pluginLifeCycle::createEshipperCarrierServicesTable();
     
    3041            PluginHealthHelper::createEshipperPluginHealthTable();
    3142        }
    32 
    33         // TODO: Remove old code
    34         pluginLifeCycle::createEshipperBoxingMasterTable();
    3543    }
    3644
     
    137145        $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_carrier_service_master");
    138146        $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_shipping_address");
    139         $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_boxing_services_master");
    140147        $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_plugin_health");
    141148
     
    151158            }
    152159        }
    153     }
    154 
    155     /*
    156      * Creating a table at the time of activation to store the boxing services in Woo-Commerce DB
    157      * @Deprecated This table is not used anymore
    158      */
    159     private static function createEshipperBoxingMasterTable()
    160     {
    161         global $wpdb;
    162         $table = $wpdb->prefix . "eshipper_boxing_services_master";
    163 
    164         wc_get_logger()->debug("Attempting to create table - $table", ['source' => 'eshipper']);
    165 
    166         $create_boxing_master_table_query = " CREATE TABLE $table(
    167             p_id int(10) NOT NULL AUTO_INCREMENT,
    168             box_name varchar(255),
    169             box_length int(10) ,
    170             box_width int(10) ,
    171             box_height int(10) ,
    172             box_weight int(10) ,
    173             max_box_weight int(10) ,
    174             created_time timestamp DEFAULT CURRENT_TIMESTAMP,
    175             PRIMARY KEY (p_id)
    176         )";
    177 
    178         require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    179         dbDelta($create_boxing_master_table_query);
    180 
    181         if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    182             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
    183         }
    184 
    185         wc_get_logger()->debug("Successfully created table - $table", ['source' => 'eshipper']);
     160
     161        // Delete old tables
     162        $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_boxing_services_master");
    186163    }
    187164
     
    208185
    209186        require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    210         dbDelta($access_tokens_query);
     187        $queryResult = dbDelta($access_tokens_query);
    211188
    212189        if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    213             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
     190            wc_get_logger()->error("Could not create table - $table \n Query Result - \n" . var_export($queryResult, true), ['source' => 'eshipper']);
    214191        }
    215192
     
    242219
    243220        require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    244         dbDelta($access_tokens_query);
     221        $queryResult = dbDelta($access_tokens_query);
    245222
    246223        if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    247             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
     224            wc_get_logger()->error("Could not create table - $table \n Query Result - \n" . var_export($queryResult, true), ['source' => 'eshipper']);
    248225        }
    249226
     
    534511
    535512        require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    536         dbDelta($create_shipping_address_query);
     513        $queryResult = dbDelta($create_shipping_address_query);
    537514
    538515        if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    539             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
     516            wc_get_logger()->error("Could not create table - $table \n Query Result - \n" . var_export($queryResult, true), ['source' => 'eshipper']);
    540517        }
    541518
     
    599576    }
    600577
    601     /*
    602      * Function to manage the boxing services in Woo-Commerce DB
    603      */
    604     public function eshipperBoxingServicesUpdate($dataArray)
    605     {
    606         global $wpdb;
    607         $box_master_table = $wpdb->prefix . "eshipper_boxing_services_master";
    608         $truncate_box_master_query = $wpdb->query("TRUNCATE TABLE $box_master_table");
    609         $finalData = $dataArray;
    610         foreach ($finalData as $i => $value) {
    611             $data = [
    612                 'box_name' => $finalData[$i]['name'],
    613                 'box_length' => $finalData[$i]['box_length'],
    614                 'box_width' => $finalData[$i]['box_width'],
    615                 'box_height' => $finalData[$i]['box_height'],
    616                 'box_weight' => $finalData[$i]['box_weight'],
    617                 'max_box_weight' => $finalData[$i]['box_max_weight'],
    618             ];
    619             $wpdb->insert(
    620                 $wpdb->prefix . 'eshipper_boxing_services_master',
    621                 $data,
    622                 ['%s', '%d', '%d', '%d', '%d', '%d',]
    623             );
    624         }
    625 
    626         $response = "Boxes have been successfuly saved";
    627 
    628         return $response;
    629     }
    630 
    631578    public static function getEshipperSettingsLink(bool $healthPage = true, bool $asyncRequest = false)
    632579    {
  • eshipper-commerce/tags/2.16.4/readme.txt

    r2984482 r3006736  
    55Tested up to: 6.3.1
    66Requires PHP: 7.1
    7 Stable tag: 2.16.3
     7Stable tag: 2.16.4
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    5454
    5555== Changelog ==
     56= 2.16.4 =
     57* Bug fix for 'Update Database' error in Plugin Health page.
     58
    5659= 2.16.3 =
    5760* Bug fix for Shipping Calculator - not able to select states when selling is allowed to one specific country in WooCommerce Settings.
     
    99102
    100103== Upgrade Notice ==
     104= 2.16.4 =
     105Bug fix for 'Update Database' error in Plugin Health page.
     106
    101107= 2.16.3 =
    102108Bug fixes for Shipping Calculator.
  • eshipper-commerce/tags/2.16.4/woocommerce-eshipper.php

    r2984482 r3006736  
    44    Plugin URI: https://ww2.eshipper.com/ecommerce/
    55    Description: Extends WooCommerce with Shipping Rates from eShipper
    6     Version: 2.16.3
     6    Version: 2.16.4
    77    Author: eShipper
    88    Author URI: https://ww2.eshipper.com/
     
    2828    get_site_option('active_sitewide_plugins')
    2929))) {
    30     define('ESHIPPER_VERSION', '2.16.3');
    31     define('ESHIPPER_VERSION_LATEST', '2.16.3');
    32     define('ESHIPPER_VERSION_DB_UPDATE', '2.15.3');
    33     //Plugin Path
     30    define('ESHIPPER_VERSION', '2.16.4');
    3431    define('ESHIPPER_PLUGIN_PATH', dirname(__FILE__));
    3532    define('ESHIPPER_PLUGIN_FILE', __FILE__);
     
    8683    add_action('wp_ajax_es_select_country_states', 'es_select_country_states');
    8784    add_action('wp_ajax_get_rates_for_shipping_calculator', 'get_rates_for_shipping_calculator');
    88 
    89 
    90     // TODO: Remove stale code
    91     add_action('wp_ajax_boxing_insert', 'boxing_insert');
    9285
    9386    function save_shipping_address()
     
    642635    }
    643636
    644 
    645     // TODO: Remove stale code
    646 
    647     /**
    648      * --------------------------------------------------------
    649      * UNUSED STALE CODE
    650      * --------------------------------------------------------
    651      */
    652 
    653     /**
    654      * Ajax function call to insert the boxing details in the db
    655      * @return void
    656      */
    657     function boxing_insert()
    658     {
    659         if ($_POST['formdata']['boxing_flag'] == "fetch") {
    660             global $wpdb;
    661             $box_master_table = $wpdb->prefix . "eshipper_boxing_services_master";
    662             $fetch_box_query = $wpdb->get_results("SELECT * FROM $box_master_table");
    663             $responseArray = ['statusCode' => "200", "boxing_data" => $fetch_box_query];
    664             echo json_encode($responseArray);
    665             die();
    666         }
    667 
    668         if ($_POST['action'] == "boxing_insert") {
    669             if (isset($_POST['formdata']) && is_array($_POST['formdata'])) {
    670                 $eshipperAuthentication = new pluginLifeCycle();
    671                 $response = $eshipperAuthentication->eshipperBoxingServicesUpdate($_POST['formdata']);
    672                 $responseArray = ['statusCode' => "200", "msg" => $response];
    673                 echo json_encode($responseArray);
    674                 die();
    675             }
    676         }
    677     }
    678 
    679     /*
    680      * Custom REST API for sending boxing information starts
    681      */
    682     /*add_action('rest_api_init',function (){
    683         register_rest_route('wl/v3','getBoxingInfo',[
    684             'methods' => 'GET',
    685             'callback' => 'send_boxing_info',
    686         ]);
    687     });*/
    688 
    689     function send_boxing_info()
    690     {
    691         global $wpdb;
    692         $box_master_table = $wpdb->prefix . "eshipper_boxing_services_master";
    693         $boxing_info = $wpdb->get_results("SELECT * FROM $box_master_table");
    694         if (count($boxing_info) > 0) {
    695             $responseArray = ['statusCode' => "200", "msg" => "Boxing Information Successfuly Fetched", "Boxing_info" => $boxing_info];
    696 
    697             return $responseArray;
    698         } else {
    699             $responseArray = ['statusCode' => "200", "msg" => "No Boxing Information Currently Available"];
    700 
    701             return $responseArray;
    702         }
    703     }
    704 
    705637    add_action('rest_api_init', function () {
    706638        register_rest_route('wl/v3', 'uninstall-eshipper-plugin', [
     
    945877        return new WP_REST_Response($responseArray, 200);
    946878    }
    947 
    948     /*
    949      * Custom REST API for sending boxing information ends
    950      */
    951879
    952880    /*Called by ajax on submit from deactivation form*/
  • eshipper-commerce/trunk/framework/db.php

    r2963096 r3006736  
    44 eshipper_db.php
    55
    6  
     6
    77 */
    88abstract class eshipper_db
    99{
    1010    public $collate;
    11     public function setup() {
     11    public function setup()
     12    {
    1213        // Create sql tables as needed.
    1314        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    1415        $this->get_collate();
    15         // Future development
    16         // if ($this->get_resource('shipments_implemented')){
    17         //     $this->sql_shipments();
    18         //     $this->sql_lists();
    19         //     $this->sql_services();
    20         // }
    21         // Done.
    2216        update_option('eshipper_version', ESHIPPER_VERSION);
    2317    }
    2418
    25     public function updateDBForVersion2_15()
     19    public function get_collate()
    2620    {
    27         if (version_compare(phpversion(), '8.0', '>=')) {
    28             require_once(ESHIPPER_PLUGIN_PATH . '/plugin/PluginHealthHelper.php');
    29 
    30             PluginHealthHelper::createEshipperPluginHealthTable();
    31         }
    32 
    33         // Shipping address table structure was updated to change 'phone_no' datatype to varchar from int
    34         pluginLifeCycle::createEshipperShippingAddressTable();
    35 
    36         update_option('eshipper_version', ESHIPPER_VERSION_LATEST);
    37     }
    38 
    39     public function get_collate() {
    4021        global $wpdb;
    41         if ($wpdb->has_cap( 'utf8mb4_520' )){
     22        if ($wpdb->has_cap('utf8mb4_520')) {
    4223            $this->collate = 'DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci';
    43         } elseif ($wpdb->has_cap( 'utf8mb4' )){
     24        } elseif ($wpdb->has_cap('utf8mb4')) {
    4425            $this->collate = 'DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci';
    4526        } else {
     
    5132
    5233    /*
    53     * Return resources
    54     */
    55     abstract function get_resource($id);
     34    * Return resources
     35    */
     36    abstract public function get_resource($id);
    5637
    5738    /*
    5839     * Date format
    5940    */
    60     public function db_datetime($datestring){
    61         if (!empty($datestring)){
     41    public function db_datetime($datestring)
     42    {
     43        if (!empty($datestring)) {
    6244            // Converts to mysql date string format
    6345            return (new DateTime($datestring))->format('Y-m-d H:i:s');
     
    6648        return '';
    6749    }
    68 
    6950}
  • eshipper-commerce/trunk/framework/plugin.php

    r2966127 r3006736  
    4343
    4444        // Database integration
    45         add_action('init', [&$this, 'eshipper_db']);
     45//        add_action('init', [&$this, 'eshipper_db']);
    4646
    4747        // Wire up product shipping options
     
    194194            wp_enqueue_script('eshipper-require-postalcode', plugins_url('lib/require-postalcode.js', ESHIPPER_PLUGIN_FILE), ['jquery'], ESHIPPER_VERSION, true);
    195195            echo '<div id="calc_shipping_postcode_required" class="hidden woocommerce-info" style="display:none">' . __(
    196                     'Zip / Postal Code is required to calculate shipping',
    197                     'woocommerce-eshipper'
    198                 ) . '</div>';
     196                'Zip / Postal Code is required to calculate shipping',
     197                'woocommerce-eshipper'
     198            ) . '</div>';
    199199        }
    200200
     
    259259
    260260        // If the plugin is deactivated, activate it again
    261         // TODO: Check if this works
    262261        require_once(ABSPATH . 'wp-admin/includes/plugin.php');
    263262        if (!is_plugin_active(plugin_basename(ESHIPPER_PLUGIN_FILE))) {
     
    265264        }
    266265
    267         /**
    268          * Updates required for Version >= 2.15.0 & < 2.16.0
    269          */
    270 
    271         // DB upgrade for version 2.15.1
    272         $version = get_option('eshipper_version', '1.0');
    273         if (version_compare($version, ESHIPPER_VERSION_DB_UPDATE, '<')) {
    274             // Get required files for db upgrade
    275             if (!class_exists('woocommerce_eshipper_db')) {
    276                 require_once(ESHIPPER_PLUGIN_PATH . '/framework/db.php');
    277                 require_once(ESHIPPER_PLUGIN_PATH . '/models/woocommerce_eshipper_db.php');
    278             }
    279             // Setup / Run Update.
    280             (new woocommerce_eshipper_db())->updateDBForVersion2_15();
    281         }
     266        // Apply DB updates
     267        pluginLifeCycle::updateDB();
     268        update_option('eshipper_version', ESHIPPER_VERSION);
    282269    }
    283270
     
    332319    {
    333320        return "<p>New feature: <b>Shipping Calculator</b><br>
    334 <ul><li>You can now test Live Shipping Rates without going through the checkout process!</li>
    335 <li>UI/UX Upgrades </li>
    336 <li>Major Bug Fixes. </li>
     321<ul><li>Bug fix for 'Update Database' error in Plugin Health page</li>
    337322</ul></p>";
    338323    }
    339324
    340325
     326    /**
     327     * @deprecated
     328     * @return void
     329     */
    341330    public function eshipper_db()
    342331    {
  • eshipper-commerce/trunk/framework/shippingmethod.php

    r2984482 r3006736  
    406406                    <?php _e('Plugin Health', 'woocommerce-eshipper') ?>
    407407                </a>
    408                 <!--            <a href="#eshipper_boxing_manager" class="nav-tab" id="eshipper_services_tab">-->
    409                 <?php //_e('Boxing Manager', 'woocommerce-eshipper')
    410                 ?><!--</a>-->
    411                 <!--<a href="#eshipper_flatrates" class="nav-tab" id="eshipper_flatrates_tab"><?php /*_e('Lettermail/Flat Rates', 'woocommerce-eshipper') */ ?></a>-->
    412                 <!--                <a href="#eshipper_shipments" class="nav-tab --><?php //echo $this->get_resource('display_shipmentstab');
    413                 ?><!--"-->
    414                 <!--                   id="eshipper_shipments_tab">--><?php //_e('Shipment Labels', 'woocommerce-eshipper')
    415                 ?><!--</a>-->
    416                 <!--<a href="#eshipper_tracking" class="nav-tab" id="eshipper_tracking_tab"><?php /*_e('Tracking', 'woocommerce-eshipper') */ ?></a>
    417             <a href="#eshipper_update" class="nav-tab" id="eshipper_update_tab"><?php /*_e('Updates', 'woocommerce-eshipper') */ ?></a>-->
    418408            </div>
    419409
     
    12771267                </div>
    12781268            </div>
    1279 
    1280             <div class="eshipper_panel eshipper_hidden" id="eshipper_boxing_manager">
    1281                 <h3><?php echo $this->get_resource('method_title') . ' ';
    1282         _e('Boxing Manager', 'woocommerce-eshipper') ?></h3>
    1283                 <table class="es_form-table">
    1284                     <tr valign="top"
    1285                         class="woocommerce-eshipper-development-api <?php if ($this->options->mode != 'dev' && $this->options->shipment_mode != 'dev') {
    1286                             echo 'hidden';
    1287                         } ?>">
    1288                         <th><?php _e('Box Dimensions', 'woocommerce-eshipper') ?></th>
    1289                         <td>
    1290                             <br/><br/>
    1291                             <table class="es_form-table" id="main_table">
    1292                                 <thead>
    1293                                 <tr>
    1294                                     <td></td>
    1295                                     <td></td>
    1296                                     <td>Name</td>
    1297                                     <td>Length(in)</td>
    1298                                     <td>Width(in)</td>
    1299                                     <td>Height(in)</td>
    1300                                     <td>Box Weight(lbs)</td>
    1301                                     <td>Max Weight(lbs)</td>
    1302                                 </tr>
    1303                                 </thead>
    1304 
    1305                                 <?php
    1306                                 global $wpdb;
    1307         $box_master_table = $wpdb->prefix . "eshipper_boxing_services_master";
    1308         $number_of_boxes = $wpdb->get_results("SELECT count(*) as count FROM $box_master_table");
    1309         ?>
    1310                                 <tbody id="boxing_manager_boxes">
    1311                                 <tr id="row_0">
    1312                                     <td></td>
    1313                                     <td><input type="checkbox" id="checkbox_box_0"></td>
    1314                                     <td><input type="text" id="box_0_name" style="min-width:50px;" placeholder="Box Name"></td>
    1315                                     <td><input type="text" id="box_0_length" style="min-width:20px;" placeholder="Length"></td>
    1316                                     <td><input type="text" id="box_0_width" style="min-width:20px;" placeholder="Width"></td>
    1317                                     <td><input type="text" id="box_0_height" style="min-width:20px;" placeholder="Height"></td>
    1318                                     <td><input type="text" id="box_0_box_weight" style="min-width:20px;" placeholder="Box Weight"></td>
    1319                                     <td><input type="text" id="box_0_max_weight" style="min-width:20px;" placeholder="Max Weight"></td>
    1320                                 </tr>
    1321                                 </tbody>
    1322                                 <tfoot>
    1323                                 <tr>
    1324                                     <td></td>
    1325                                     <td></td>
    1326                                     <td>
    1327                                         <button type="button" id="add_box_btn">Add Box</button>
    1328                                     </td>
    1329                                     <td>
    1330                                         <button type="button" id="remove_box_btn">Remove Selected Box/Boxes</button>
    1331                                     </td>
    1332                                     <!--<td><button type="button" id="remove_box_btn">Remove Box</button></td>-->
    1333                                 </tr>
    1334                                 </tfoot>
    1335                             </table>
    1336                             <br/>
    1337                             <script type="text/javascript">
    1338                                 jQuery(document).ready(function () {
    1339 
    1340                                     var get_boxing_form_data = {
    1341                                         "boxing_flag": "fetch"
    1342                                     }
    1343                                     jQuery.ajax({
    1344                                         type: "post",
    1345                                         dataType: "json",
    1346                                         url: ajaxurl,
    1347                                         data: {
    1348                                             action: "boxing_insert",
    1349                                             formdata: get_boxing_form_data,
    1350                                         },
    1351                                         success: function (response) {
    1352                                             var number_of_boxes = (response.boxing_data.length);
    1353                                             if (number_of_boxes > 0) {
    1354                                                 jQuery("#boxing_manager_boxes").html("");
    1355                                             }
    1356 
    1357                                             for (var i = 0; i < number_of_boxes; i++) {
    1358                                                 jQuery("#boxing_manager_boxes").append("" +
    1359                                                     "<tr id='row_" + i + "'>" +
    1360                                                     "<td></td>" +
    1361                                                     "<td><input type='checkbox' id='checkbox_box_" + i + "'></td>" +
    1362                                                     "<td><input type='text'  id='box_" + i + "_name' style='min-width:20px;' placeholder='Box Name' value='" + response.boxing_data[i].box_name + "'></td>" +
    1363                                                     "<td><input type='text'  id='box_" + i + "_length' style='min-width:20px;' placeholder='Length' value='" + response.boxing_data[i].box_length + "'></td>" +
    1364                                                     "<td><input type='text'  id='box_" + i + "_width' style='min-width:20px;' placeholder='Width' value='" + response.boxing_data[i].box_width + "'></td>" +
    1365                                                     "<td><input type='text'  id='box_" + i + "_height' style='min-width:20px;' placeholder='Height' value='" + response.boxing_data[i].box_height + "'></td>" +
    1366                                                     "<td><input type='text'  id='box_" + i + "_box_weight' style='min-width:20px;' placeholder='Box Weight' value='" + response.boxing_data[i].box_weight + "'></td>" +
    1367                                                     "<td><input type='text'  id='box_" + i + "_max_weight' style='min-width:20px;' placeholder='Max Weight' value='" + response.boxing_data[i].max_box_weight + "'></td>" +
    1368                                                     "</tr>"
    1369                                                 );
    1370                                             }
    1371                                         }
    1372                                     });
    1373 
    1374 
    1375                                     //Onclick of remove box button
    1376                                     jQuery("body").on('click', '#remove_box_btn', function (event) {
    1377                                         event.preventDefault();
    1378                                         var check_flag = [];
    1379                                         var check_ids = [];  //array to store the id of the checkboxes that have been checked for removal
    1380                                         var finalCheckArray = {};
    1381                                         for (var i = 0; i < 10; i++) {
    1382                                             check_flag[i] = jQuery("#checkbox_box_" + i).is(":checked");
    1383                                             if (check_flag[i] == true) {
    1384                                                 check_ids.push(i);
    1385                                             }
    1386                                         }
    1387                                         for (var remove_counter = 0; remove_counter < check_ids.length; remove_counter++) {
    1388                                             jQuery("#row_" + check_ids[remove_counter]).remove();
    1389                                         }
    1390 
    1391                                     });
    1392 
    1393 
    1394                                     //On click of add button in boxing manager settings
    1395                                     jQuery("body").on('click', '#add_box_btn', function (event) {
    1396                                         event.preventDefault();
    1397                                         var id = (jQuery('#main_table tbody tr:last').index());
    1398                                         id = id + 1;
    1399                                         jQuery("#main_table").append("" +
    1400                                             "<tr id='row_" + id + "'>" +
    1401                                             "<td></td>" +
    1402                                             "<td><input type='checkbox' id='checkbox_box_" + id + "'></td>" +
    1403                                             "<td><input type='text'  id='box_" + id + "_name' style='min-width:50px;' placeholder='Box Name'></td>" +
    1404                                             "<td><input type='text'  id='box_" + id + "_length' style='min-width:20px;' placeholder='Length'></td>" +
    1405                                             "<td><input type='text'  id='box_" + id + "_width' style='min-width:20px;' placeholder='Width'></td>" +
    1406                                             "<td><input type='text'  id='box_" + id + "_height' style='min-width:20px;' placeholder='Height'></td>" +
    1407                                             "<td><input type='text'  id='box_" + id + "_box_weight' style='min-width:20px;' placeholder='Box Weight'></td>" +
    1408                                             "<td><input type='text'  id='box_" + id + "_max_weight' style='min-width:20px;' placeholder='Max Weight'></td>" +
    1409                                             "</td>" +
    1410                                             "</tr>"
    1411                                         );
    1412                                     });
    1413 
    1414                                     //Onclick of save button in boxing manager settings
    1415                                     jQuery("body").on('click', '#save_boxing_options', function (event) {
    1416                                         event.preventDefault();
    1417                                         var finalArray = {};
    1418                                         for (var i = 0; i < 10; i++) {
    1419                                             var j = i;
    1420                                             var finalSubArray = {};
    1421                                             finalSubArray.name = jQuery("#box_" + j + "_name").val();
    1422                                             finalSubArray.box_length = jQuery("#box_" + j + "_length").val();
    1423                                             finalSubArray.box_width = jQuery("#box_" + j + "_width").val();
    1424                                             finalSubArray.box_height = jQuery("#box_" + j + "_height").val();
    1425                                             finalSubArray.box_weight = jQuery("#box_" + j + "_box_weight").val();
    1426                                             finalSubArray.box_max_weight = jQuery("#box_" + j + "_max_weight").val();
    1427                                             finalArray[i] = finalSubArray;
    1428                                         }
    1429 
    1430                                         jQuery.ajax({
    1431                                             type: "post",
    1432                                             dataType: "json",
    1433                                             url: ajaxurl,
    1434                                             data: {
    1435                                                 action: "boxing_insert",
    1436                                                 formdata: finalArray,
    1437                                             },
    1438                                             success: function (response) {
    1439                                                 if (response.statusCode == 200) {
    1440                                                     jQuery("#boxing_save_message_display").text(response.msg);
    1441                                                     jQuery("#boxing_save_message_display").css('color', 'green');
    1442                                                 }
    1443 
    1444                                             }
    1445                                         });
    1446                                     });
    1447                                 });
    1448                             </script>
    1449 
    1450                             <button type="submit" name="save_boxing_options" value="save_boxing_options" id="save_boxing_options">Save Boxing
    1451                                 Information
    1452                             </button>
    1453                             <br/><br/>
    1454                             <div id="boxing_save_message_display"></div>
    1455                         </td>
    1456                     </tr>
    1457                 </table>
    1458             </div>
    14591269        </div>
    14601270
  • eshipper-commerce/trunk/plugin/PluginHealthHelper.php

    r2984482 r3006736  
    6565        $create_plugin_health_table = " CREATE TABLE $table($columns
    6666            created_time timestamp DEFAULT CURRENT_TIMESTAMP,
    67             updated_time timestamp DEFAULT NULL
     67            updated_time timestamp DEFAULT CURRENT_TIMESTAMP
    6868        )";
    6969
    7070        require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    71         dbDelta($create_plugin_health_table);
     71        $queryResult = dbDelta($create_plugin_health_table);
    7272
    7373        // Check if table exists at this point before proceeding.
     
    7575        global $wpdb;
    7676        if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    77             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
     77            wc_get_logger()->error("Could not create table - $table \n Query Result - \n" . var_export($queryResult, true), ['source' => 'eshipper']);
    7878            return false;
    7979        }
  • eshipper-commerce/trunk/plugin/pluginLifeCycle.php

    r2963096 r3006736  
    2323
    2424        // Create all required tables for the plugin
     25        self::updateDB();
     26    }
     27
     28    /**
     29     * Create/update all required tables for the plugin
     30     * @return void
     31     */
     32    public static function updateDB()
     33    {
     34        // All methods called here use dbDelta to create/update the tables
     35        // and hence always contain the latest structure of the table
    2536        pluginLifeCycle::createEshipperAccessTokensTable();
    2637        pluginLifeCycle::createEshipperCarrierServicesTable();
     
    3041            PluginHealthHelper::createEshipperPluginHealthTable();
    3142        }
    32 
    33         // TODO: Remove old code
    34         pluginLifeCycle::createEshipperBoxingMasterTable();
    3543    }
    3644
     
    137145        $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_carrier_service_master");
    138146        $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_shipping_address");
    139         $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_boxing_services_master");
    140147        $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_plugin_health");
    141148
     
    151158            }
    152159        }
    153     }
    154 
    155     /*
    156      * Creating a table at the time of activation to store the boxing services in Woo-Commerce DB
    157      * @Deprecated This table is not used anymore
    158      */
    159     private static function createEshipperBoxingMasterTable()
    160     {
    161         global $wpdb;
    162         $table = $wpdb->prefix . "eshipper_boxing_services_master";
    163 
    164         wc_get_logger()->debug("Attempting to create table - $table", ['source' => 'eshipper']);
    165 
    166         $create_boxing_master_table_query = " CREATE TABLE $table(
    167             p_id int(10) NOT NULL AUTO_INCREMENT,
    168             box_name varchar(255),
    169             box_length int(10) ,
    170             box_width int(10) ,
    171             box_height int(10) ,
    172             box_weight int(10) ,
    173             max_box_weight int(10) ,
    174             created_time timestamp DEFAULT CURRENT_TIMESTAMP,
    175             PRIMARY KEY (p_id)
    176         )";
    177 
    178         require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    179         dbDelta($create_boxing_master_table_query);
    180 
    181         if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    182             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
    183         }
    184 
    185         wc_get_logger()->debug("Successfully created table - $table", ['source' => 'eshipper']);
     160
     161        // Delete old tables
     162        $wpdb->query("DROP TABLE {$wpdb->prefix}eshipper_boxing_services_master");
    186163    }
    187164
     
    208185
    209186        require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    210         dbDelta($access_tokens_query);
     187        $queryResult = dbDelta($access_tokens_query);
    211188
    212189        if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    213             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
     190            wc_get_logger()->error("Could not create table - $table \n Query Result - \n" . var_export($queryResult, true), ['source' => 'eshipper']);
    214191        }
    215192
     
    242219
    243220        require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    244         dbDelta($access_tokens_query);
     221        $queryResult = dbDelta($access_tokens_query);
    245222
    246223        if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    247             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
     224            wc_get_logger()->error("Could not create table - $table \n Query Result - \n" . var_export($queryResult, true), ['source' => 'eshipper']);
    248225        }
    249226
     
    534511
    535512        require_once(ABSPATH . "wp-admin/includes/upgrade.php");
    536         dbDelta($create_shipping_address_query);
     513        $queryResult = dbDelta($create_shipping_address_query);
    537514
    538515        if ($wpdb->get_var("SHOW TABLES LIKE '$table'") !== $table) {
    539             wc_get_logger()->error("Could not create table - $table", ['source' => 'eshipper']);
     516            wc_get_logger()->error("Could not create table - $table \n Query Result - \n" . var_export($queryResult, true), ['source' => 'eshipper']);
    540517        }
    541518
     
    599576    }
    600577
    601     /*
    602      * Function to manage the boxing services in Woo-Commerce DB
    603      */
    604     public function eshipperBoxingServicesUpdate($dataArray)
    605     {
    606         global $wpdb;
    607         $box_master_table = $wpdb->prefix . "eshipper_boxing_services_master";
    608         $truncate_box_master_query = $wpdb->query("TRUNCATE TABLE $box_master_table");
    609         $finalData = $dataArray;
    610         foreach ($finalData as $i => $value) {
    611             $data = [
    612                 'box_name' => $finalData[$i]['name'],
    613                 'box_length' => $finalData[$i]['box_length'],
    614                 'box_width' => $finalData[$i]['box_width'],
    615                 'box_height' => $finalData[$i]['box_height'],
    616                 'box_weight' => $finalData[$i]['box_weight'],
    617                 'max_box_weight' => $finalData[$i]['box_max_weight'],
    618             ];
    619             $wpdb->insert(
    620                 $wpdb->prefix . 'eshipper_boxing_services_master',
    621                 $data,
    622                 ['%s', '%d', '%d', '%d', '%d', '%d',]
    623             );
    624         }
    625 
    626         $response = "Boxes have been successfuly saved";
    627 
    628         return $response;
    629     }
    630 
    631578    public static function getEshipperSettingsLink(bool $healthPage = true, bool $asyncRequest = false)
    632579    {
  • eshipper-commerce/trunk/readme.txt

    r2984482 r3006736  
    55Tested up to: 6.3.1
    66Requires PHP: 7.1
    7 Stable tag: 2.16.3
     7Stable tag: 2.16.4
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    5454
    5555== Changelog ==
     56= 2.16.4 =
     57* Bug fix for 'Update Database' error in Plugin Health page.
     58
    5659= 2.16.3 =
    5760* Bug fix for Shipping Calculator - not able to select states when selling is allowed to one specific country in WooCommerce Settings.
     
    99102
    100103== Upgrade Notice ==
     104= 2.16.4 =
     105Bug fix for 'Update Database' error in Plugin Health page.
     106
    101107= 2.16.3 =
    102108Bug fixes for Shipping Calculator.
  • eshipper-commerce/trunk/woocommerce-eshipper.php

    r2984482 r3006736  
    44    Plugin URI: https://ww2.eshipper.com/ecommerce/
    55    Description: Extends WooCommerce with Shipping Rates from eShipper
    6     Version: 2.16.3
     6    Version: 2.16.4
    77    Author: eShipper
    88    Author URI: https://ww2.eshipper.com/
     
    2828    get_site_option('active_sitewide_plugins')
    2929))) {
    30     define('ESHIPPER_VERSION', '2.16.3');
    31     define('ESHIPPER_VERSION_LATEST', '2.16.3');
    32     define('ESHIPPER_VERSION_DB_UPDATE', '2.15.3');
    33     //Plugin Path
     30    define('ESHIPPER_VERSION', '2.16.4');
    3431    define('ESHIPPER_PLUGIN_PATH', dirname(__FILE__));
    3532    define('ESHIPPER_PLUGIN_FILE', __FILE__);
     
    8683    add_action('wp_ajax_es_select_country_states', 'es_select_country_states');
    8784    add_action('wp_ajax_get_rates_for_shipping_calculator', 'get_rates_for_shipping_calculator');
    88 
    89 
    90     // TODO: Remove stale code
    91     add_action('wp_ajax_boxing_insert', 'boxing_insert');
    9285
    9386    function save_shipping_address()
     
    642635    }
    643636
    644 
    645     // TODO: Remove stale code
    646 
    647     /**
    648      * --------------------------------------------------------
    649      * UNUSED STALE CODE
    650      * --------------------------------------------------------
    651      */
    652 
    653     /**
    654      * Ajax function call to insert the boxing details in the db
    655      * @return void
    656      */
    657     function boxing_insert()
    658     {
    659         if ($_POST['formdata']['boxing_flag'] == "fetch") {
    660             global $wpdb;
    661             $box_master_table = $wpdb->prefix . "eshipper_boxing_services_master";
    662             $fetch_box_query = $wpdb->get_results("SELECT * FROM $box_master_table");
    663             $responseArray = ['statusCode' => "200", "boxing_data" => $fetch_box_query];
    664             echo json_encode($responseArray);
    665             die();
    666         }
    667 
    668         if ($_POST['action'] == "boxing_insert") {
    669             if (isset($_POST['formdata']) && is_array($_POST['formdata'])) {
    670                 $eshipperAuthentication = new pluginLifeCycle();
    671                 $response = $eshipperAuthentication->eshipperBoxingServicesUpdate($_POST['formdata']);
    672                 $responseArray = ['statusCode' => "200", "msg" => $response];
    673                 echo json_encode($responseArray);
    674                 die();
    675             }
    676         }
    677     }
    678 
    679     /*
    680      * Custom REST API for sending boxing information starts
    681      */
    682     /*add_action('rest_api_init',function (){
    683         register_rest_route('wl/v3','getBoxingInfo',[
    684             'methods' => 'GET',
    685             'callback' => 'send_boxing_info',
    686         ]);
    687     });*/
    688 
    689     function send_boxing_info()
    690     {
    691         global $wpdb;
    692         $box_master_table = $wpdb->prefix . "eshipper_boxing_services_master";
    693         $boxing_info = $wpdb->get_results("SELECT * FROM $box_master_table");
    694         if (count($boxing_info) > 0) {
    695             $responseArray = ['statusCode' => "200", "msg" => "Boxing Information Successfuly Fetched", "Boxing_info" => $boxing_info];
    696 
    697             return $responseArray;
    698         } else {
    699             $responseArray = ['statusCode' => "200", "msg" => "No Boxing Information Currently Available"];
    700 
    701             return $responseArray;
    702         }
    703     }
    704 
    705637    add_action('rest_api_init', function () {
    706638        register_rest_route('wl/v3', 'uninstall-eshipper-plugin', [
     
    945877        return new WP_REST_Response($responseArray, 200);
    946878    }
    947 
    948     /*
    949      * Custom REST API for sending boxing information ends
    950      */
    951879
    952880    /*Called by ajax on submit from deactivation form*/
Note: See TracChangeset for help on using the changeset viewer.