Changeset 2913178
- Timestamp:
- 05/16/2023 06:19:51 PM (3 years ago)
- Location:
- midwest-logistics/trunk
- Files:
-
- 1 added
- 8 edited
-
classes/class-ml-api.php (added)
-
classes/class-ml-settings.php (modified) (2 diffs)
-
classes/class-ml-stock.php (modified) (4 diffs)
-
classes/class-wc-ml-shipping-options.php (modified) (1 diff)
-
inc/orderFunctions.php (modified) (1 diff)
-
inc/productFunctions.php (modified) (5 diffs)
-
inc/trackingFunctions.php (modified) (2 diffs)
-
midwest-wholesale.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
midwest-logistics/trunk/classes/class-ml-settings.php
r2529939 r2913178 32 32 'Midwest_Logistics_plugin_Page' 33 33 ); 34 35 add_settings_field( 36 'Midwest_Logistics_api_version', 37 __( 'API Version:', 'Midwest_Logistics' ), 38 array($this,'Midwest_Logistics_api_version_render'), 39 'Midwest_Logistics_plugin_Page', 40 'Midwest_Logistics_Midwest_Logistics_plugin_Page_section' 41 ); 34 42 add_settings_field( 35 43 'Midwest_Logistics_text_field_0', … … 125 133 ?> 126 134 <input type='text' name='Midwest_Logistics_settings[Midwest_Logistics_API_Key_field_0]' value='<?php echo $value ?>'> 135 <?php 136 } 137 public function Midwest_Logistics_api_version_render() { 138 $options = get_option( 'Midwest_Logistics_settings' ); 139 ?> 140 <select name='Midwest_Logistics_settings[Midwest_Logistics_api_version]'> 141 <option value='1' <?php selected( $options['Midwest_Logistics_api_version'], 1 ); ?>>API Version 1.0.0 (Current)</option> 142 <option value='2' <?php selected( $options['Midwest_Logistics_api_version'], 2 ); ?>>API Version 2.0.0 (Beta)</option> 143 </select> 127 144 <?php 128 145 } -
midwest-logistics/trunk/classes/class-ml-stock.php
r2481617 r2913178 49 49 50 50 $skusResults = $this->get_SKUs(); 51 51 52 $skus = false; 52 53 $skusArray = array(); 54 $skusJSONArray = array(); 53 55 if(count($skusResults) == 0) { 54 56 //we must have updated them all so reset the field … … 58 60 59 61 if(count($skusResults) > 0) { 60 foreach ($skusResults as $singleSKU) { 62 foreach ($skusResults as $singleSKU) { 61 63 $skus .= $singleSKU["midwestSKU"] . ","; 62 64 $skusJSONArray[] = $singleSKU["midwestSKU"]; 63 65 $skusArray[$singleSKU["midwestSKU"]] = array("id"=>$singleSKU["post_id"]); 64 66 … … 83 85 "request" => "productcheckbylist" 84 86 ]; 85 86 $postString = json_encode ($jsonArray);87 87 88 $args = array(89 'body' => $postString,90 'timeout' => '60',91 'redirection' => '5',92 'httpversion' => '1.0',93 'blocking' => true,94 'headers' => array(),95 'cookies' => array()96 );97 88 98 $wp_remote_post_response = wp_remote_post( MIDWESTLOGISTICS_API_URL,$args); 99 if(is_wp_error($wp_remote_post_response)) { 100 $httpcode = "500"; 101 $code = $wp_remote_post_response->get_error_code(); 102 $response = $wp_remote_post_response->get_error_messages($code); 103 if(is_array($response)) { 104 $response = $response[0]; 105 } 89 $API = new ML_API(); 90 $APIVersion = $API->get_api_version(); 91 //switch the SKUs for a array 92 if($APIVersion == "2") { 93 $jsonArray["sku"] = $skusJSONArray; 94 } 95 106 96 107 } else { 108 $httpcode = wp_remote_retrieve_response_code( $wp_remote_post_response ); 109 $response = $wp_remote_post_response["body"]; 110 } 97 $httpcode = "500"; 98 $postString = json_encode ($jsonArray); 99 100 $response = $API->send($postString); 101 if($response != null) { 102 $httpcode = $response["code"]; 103 $response = $response["response"]; 104 } 111 105 112 106 if($httpcode == "200") { … … 167 161 $ML_Stock = new ML_Stock(); 168 162 163 //add_action( 'init', 'test_run_start' ); 164 function test_run_start() { 165 $ML_Stock = new ML_Stock(); 166 $ML_Stock->get_inventory(); 167 168 } -
midwest-logistics/trunk/classes/class-wc-ml-shipping-options.php
r2481617 r2913178 50 50 ]; 51 51 52 $midwest_logistics_api_key = $settingOptions["Midwest_Logistics_API_Key_field_0"];53 $midwest_logistics_customer_key = $settingOptions["Midwest_Logistics_customer_id_text_field_1"];54 52 $postString = json_encode ($jsonArray); 55 $args = array( 56 'body' => $postString, 57 'timeout' => '60', 58 'redirection' => '5', 59 'httpversion' => '1.0', 60 'blocking' => true, 61 'headers' => array(), 62 'cookies' => array() 63 ); 64 65 66 67 $wp_remote_post_response = wp_remote_post( MIDWESTLOGISTICS_API_URL,$args); 68 if(is_wp_error($wp_remote_post_response)) { 69 $httpcode = "500"; 70 $code = $wp_remote_post_response->get_error_code(); 71 $response = $wp_remote_post_response->get_error_messages($code); 72 if(is_array($response)) { 73 $response = $response[0]; 74 } 75 76 } else { 77 $httpcode = wp_remote_retrieve_response_code( $wp_remote_post_response ); 78 $response = $wp_remote_post_response["body"]; 53 54 $httpcode = "500"; 55 $API = new ML_API(); 56 $response = $API->send($postString); 57 if($response != null) { 58 $httpcode = $response["code"]; 59 $response = $response["response"]; 79 60 } 80 61 81 62 $responseText = ""; 82 63 -
midwest-logistics/trunk/inc/orderFunctions.php
r2529939 r2913178 226 226 ] 227 227 ]; 228 229 $httpcode = "500"; 230 $postString = json_encode ($jsonArray); 228 231 229 $postString = json_encode ($jsonArray); 230 $args = array( 231 'body' => $postString, 232 'timeout' => '60', 233 'redirection' => '5', 234 'httpversion' => '1.0', 235 'blocking' => true, 236 'headers' => array(), 237 'cookies' => array() 238 ); 239 $wp_remote_post_response = wp_remote_post( MIDWESTLOGISTICS_API_URL,$args); 240 if(is_wp_error($wp_remote_post_response)) { 241 $httpcode = "500"; 242 $code = $wp_remote_post_response->get_error_code(); 243 $response = $wp_remote_post_response->get_error_messages($code); 244 if(is_array($response)) { 245 $response = $response[0]; 246 } 247 248 } else { 249 $httpcode = wp_remote_retrieve_response_code( $wp_remote_post_response ); 250 $response = $wp_remote_post_response["body"]; 251 } 252 //$ch = curl_init( MIDWESTLOGISTICS_API_URL ); 253 //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 254 //curl_setopt($ch, CURLOPT_POSTFIELDS, $postString); 255 //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 256 //$response = curl_exec( $ch ); 257 //$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 232 233 234 $API = new ML_API(); 235 $response = $API->send($postString); 236 if($response != null) { 237 $httpcode = $response["code"]; 238 $response = $response["response"]; 239 } 240 258 241 $responseText = ""; 259 242 if($httpcode == "200") { -
midwest-logistics/trunk/inc/productFunctions.php
r2481617 r2913178 146 146 "request" => "productcheck" 147 147 ]; 148 $postString = json_encode ($jsonArray); 149 150 $args = array( 151 'method' => 'POST', 152 'body' => $postString, 153 'timeout' => '60', 154 'redirection' => '5', 155 'httpversion' => '1.0', 156 'blocking' => true, 157 'headers' => array(), 158 'sslverify' => true 159 ); 160 161 $wp_remote_post_response = wp_remote_post( MIDWESTLOGISTICS_API_URL,$args); 162 if(is_wp_error($wp_remote_post_response)) { 163 $httpcode = "500"; 164 $code = $wp_remote_post_response->get_error_code(); 165 $response = $wp_remote_post_response->get_error_messages($code); 166 if(is_array($response)) { 167 $response = $response[0]; 168 } 169 170 } else { 171 $httpcode = wp_remote_retrieve_response_code( $wp_remote_post_response ); 172 $response = $wp_remote_post_response["body"]; 173 } 174 175 176 //$ch = curl_init( MIDWESTLOGISTICS_API_URL ); 177 //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 178 //curl_setopt($ch, CURLOPT_POSTFIELDS, $postString); 179 //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 180 181 //$response = curl_exec( $ch ); 182 //$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 148 149 $httpcode = "500"; 150 $postString = json_encode ($jsonArray); 151 $API = new ML_API(); 152 $response = $API->send($postString); 153 if($response != null) { 154 $httpcode = $response["code"]; 155 $response = $response["response"]; 156 } 157 183 158 $responseText = ""; 184 159 185 160 186 161 if($httpcode == "200") { 187 162 if(json_decode($response) !== null) { 188 163 $jsonResponse = json_decode($response); 189 $curl_result = $jsonResponse -> {"result"}; 164 165 $curl_result = $jsonResponse -> {"result"}; 166 190 167 if($curl_result === "200") { 191 168 $responseText = $jsonResponse -> {"message"}; … … 194 171 $responseText = $jsonResponse -> {"message"}; 195 172 $responseArray = array("result" => false, "message" => $jsonResponse -> {"message"}); 173 196 174 } 197 175 } else { … … 202 180 } 203 181 204 if($httpcode == "500") { 182 if($httpcode == "500") { 205 183 new WP_Error( MIDWESTLOGISTICS_NAME . ' API',MIDWESTLOGISTICS_NAME . " API is down." ); 206 184 $responseText = MIDWESTLOGISTICS_NAME . " API is down."; … … 210 188 //add the log 211 189 midwest_logistics_add_communication_log($postString,$response,get_the_ID(),"product",get_the_title(),$responseText); 212 //var_dump($responseArray);213 190 return $responseArray; 214 191 } … … 232 209 if( !empty( $midwest_logistics_product_sku_text_field_value ) ) { 233 210 if($midwest_logistics_product_sku_text_field_value !== "") { 211 234 212 $responseArray = midwest_logisitcs_verify_sku_number($midwest_logistics_product_sku_text_field_value); 235 213 if(is_array($responseArray)) { 236 214 237 215 if($responseArray["result"] === false) { 216 238 217 if($responseArray["message"] == "The API key is invalid") { 239 218 ?> -
midwest-logistics/trunk/inc/trackingFunctions.php
r2529939 r2913178 75 75 } 76 76 } 77 77 78 78 if(count($orderArray) > 0) { 79 79 get_midwest_logistics_tracking_information($orderArray); … … 93 93 $midwest_logistics_customer_key = $settingOptions["Midwest_Logistics_customer_id_text_field_1"]; 94 94 } 95 $postString = '{"apiKey":"' . $apiKey . '","customerId": "' . $midwest_logistics_customer_key . '","request":"orderStatus","orders":['; 95 96 $orders = []; 96 97 foreach ($orderArray as $orderArraySingle) { 97 $orderString .= "{ \"orderId\": \"\",\"CRMID\" : \"" . $orderArraySingle["CRMID"] . "\" },"; 98 } 99 if($orderString !== "") { 100 $orderString = substr($orderString,0,strlen($orderString)-1); 101 $postString .= $orderString ."]}"; 102 } 103 $args = array( 104 'body' => $postString, 105 'timeout' => '60', 106 'redirection' => '5', 107 'httpversion' => '1.0', 108 'blocking' => true, 109 'headers' => array(), 110 'cookies' => array() 111 ); 112 113 $wp_remote_post_response = wp_remote_post( MIDWESTLOGISTICS_API_URL,$args); 114 if(is_wp_error($wp_remote_post_response)) { 115 $httpcode = "500"; 116 $code = $wp_remote_post_response->get_error_code(); 117 $response = $wp_remote_post_response->get_error_messages($code); 118 if(is_array($response)) { 119 $response = $response[0]; 120 } 121 } else { 122 $httpcode = wp_remote_retrieve_response_code( $wp_remote_post_response ); 123 $response = $wp_remote_post_response["body"]; 124 } 125 126 127 128 //$ch = curl_init( MIDWESTLOGISTICS_API_URL ); 129 //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 130 //curl_setopt($ch, CURLOPT_POSTFIELDS, $postString); 131 //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 132 //$response = curl_exec( $ch ); 133 //$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 98 $orders[] = array( 99 "orderId" => "", 100 "CRMID" => $orderArraySingle["CRMID"] 101 ); 102 } 103 $jsonArray = [ 104 "apiKey" => $apiKey, 105 "customerId" => $midwest_logistics_customer_key, 106 "request" => "orderStatus", 107 "orders" => $orders 108 ]; 109 print_r($jsonArray); 110 $httpcode = "500"; 111 $postString = json_encode ($jsonArray); 112 $API = new ML_API(); 113 $response = $API->send($postString); 114 if($response != null) { 115 $httpcode = $response["code"]; 116 $response = $response["response"]; 117 } 134 118 135 119 $responseText = ""; -
midwest-logistics/trunk/midwest-wholesale.php
r2893907 r2913178 4 4 * Plugin URI: https://plugins.skynet-solutions.net/ 5 5 * Description: Midwest Wholesale Plugin allows you to automatically add Woocommerce orders into the Midwest Logistics order system. 6 * Version: 1.1. 196 * Version: 1.1.20 7 7 * WC requires at least: 3.0.0 8 * WC tested up to: 7.5.18 * WC tested up to: 6.1.1 9 9 * Author: Skynet Solutions Inc. 10 10 * Author URI: http://www.skynet-solutions.net/ … … 81 81 82 82 } 83 84 //This is being faded out but left for right now. Setting is now in class-ML-API 83 85 if ( !defined( 'MIDWESTLOGISTICS_API_URL' ) ) { 84 86 //define( 'MIDWESTLOGISTICS_API_URL', 'http://midwestlogistics.windev.skynet-solutions.net/api/json/' ); … … 114 116 115 117 if($apiKey <> "") { 118 require_once( MIDWESTLOGISTICS_PATH . 'classes/class-ml-api.php' ); 116 119 require_once( MIDWESTLOGISTICS_PATH . 'classes/class-wc-ml-shipping-options.php' ); 117 120 require_once( MIDWESTLOGISTICS_PATH . 'classes/class-ml-settings-orders.php' ); -
midwest-logistics/trunk/readme.txt
r2893907 r2913178 3 3 Tags: Midwest Logistics, Distribution, Shipping 4 4 Requires at least: 4.0 5 Tested up to: 6.2.05 Tested up to: 5.9.0 6 6 Requires PHP: 5.4 7 Stable tag: 1.1. 197 Stable tag: 1.1.20 8 8 License: GPLv3 9 9
Note: See TracChangeset
for help on using the changeset viewer.