• forgetme

    (@forgetme)


    Original Reference bug posts:
    https://developers.easyship.com/discuss/5d062b48c15712001f40dacd
    https://developers.easyship.com/discuss/5e465a04897ba100127ec380

    When looking through the debug logs I noticed that my error logs are filling up with the following 3 error messages.

    PHP Notice: Undefined index: es_api_key in /home/forgetme/public_html/wp-content/plugins/easyship-woocommerce-shipping-rates/includes/easyship-api.php on line 32
    PHP Notice: Undefined index: es_api_secret in /home/forgetme/public_html/wp-content/plugins/easyship-woocommerce-shipping-rates/includes/easyship-api.php on line 33
    PHP Notice: Undefined index: es_taxes_duties in /home/forgetme/public_html/wp-content/plugins/easyship-woocommerce-shipping-rates/includes/easyship-api.php on line 36
    I like using your product for my shipping needs, but this plug-in doesn’t get fixed soon then I”m going to need to start looking for a different shipping partner since this is impact the performance of my Woocommerce site.

    Additional info that might be helpful:
    WordPress version: 5.3.2
    WooCommerce version: 3.9.2
    PHP version: 7.3.14

Viewing 1 replies (of 1 total)
  • Thread Starter forgetme

    (@forgetme)

    Since Easyship has been no help on this issue, I took it upon myself to learn how to fix it myself here are the instructions for anyone that wants to getting these 3 Undefined Index errors in their debug log.

    Open and edit plugin code: /wp-content/plugins/easyship-woocommerce-shipping-rates/includes/easyship-api.php

    Find line 29: public static function init($token = null)

    Replace lines 29-59 with the following:

    
        public static function init($token = null) {
            $Easyship_Shipping_Method = new Easyship_Shipping_Method();
            if(isset($Easyship_Shipping_Method->settings['es_api_key'])) {
                self::$apikey = trim( esc_attr( $Easyship_Shipping_Method->settings['es_api_key'] ), " " );
            }
            if(isset($Easyship_Shipping_Method->settings['es_api_key'])) {
                self::$apiSecret = str_replace( '\n', "\n", $Easyship_Shipping_Method->settings['es_api_secret'] );
            }
            // if incoterms/insurance already exist on WC, send it with API
            self::$is_insured = 0;
            if(isset($Easyship_Shipping_Method->settings['es_api_key'])) {
                self::$taxes_duties_paid_by = $Easyship_Shipping_Method->settings['es_taxes_duties'];
            }
            self::$_currency = get_woocommerce_currency();
            // feature/access_token
            if (!is_null($token)) {
                self::$accessToken = trim(esc_attr($token), " ");
            } else {
                $token_option_name = 'es_access_token_' . get_current_network_id();
                self::$accessToken = trim(esc_attr(get_option($token_option_name)), " ");
            }
    
            // sandbox mode
            // if ( $Easyship_Shipping_Method->settings['es_sandbox_mode'] == 'yes' ) {
            //     self::$oauth_url = "https://auth-sandbox.easyship.com/oauth2/token";
            //     self::$api_url = "https://api-sandbox.easyship.com/rate/v1/woocommerce";
            // }
            if ((self::$apikey == '' || self::$apiSecret == '') && self::$accessToken == '') {
                throw new Exception('Missing API Key and API Secret OR Access Token!');
            }
        }
    

    Your done no more undefined index errors. Note that since this is an edit to the code, you will have to redo it every time Easyship updates their plugin unless they see this and actually fix in their distribution of the plugin.

Viewing 1 replies (of 1 total)
  • The topic ‘3 Undefined index errors.’ is closed to new replies.