Changeset 2753584
- Timestamp:
- 07/08/2022 07:38:41 AM (4 years ago)
- Location:
- fastpicker/trunk
- Files:
-
- 9 edited
-
fastpicker.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
src/Views/Settings.php (modified) (1 diff)
-
src/WooOrderpicker/API/OrderShipping.php (modified) (2 diffs)
-
src/WooOrderpicker/API/Shipping.php (modified) (2 diffs)
-
src/WooOrderpicker/API/ShippingLabel.php (modified) (2 diffs)
-
src/WooOrderpicker/Admin.php (modified) (2 diffs)
-
src/WooOrderpicker/Utils/Helper.php (modified) (1 diff)
-
src/WooOrderpicker/Webhook.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fastpicker/trunk/fastpicker.php
r2708206 r2753584 4 4 * Plugin URI: https://fastpicker.io/ 5 5 * Description: Plugin to connect with FastPicker 6 * Version: 1.0.1 7 * Tested up to: 5.9 8 * Stable tag: 1.0.1 6 * Version: 1.0.2 9 7 * License: GPLv2 or later 10 * Text Domain: FastPicker8 * Text Domain: fastpicker 11 9 */ 12 10 13 define('WOO_ORDERPICKER_PLUGIN_VERSION', '1.0. 1');11 define('WOO_ORDERPICKER_PLUGIN_VERSION', '1.0.2'); 14 12 define('WOO_ORDERPICKER_PLUGIN_DIR', plugin_dir_path( __FILE__ )); 15 13 define('WOO_ORDERPICKER_PLUGIN_URL', plugin_dir_url( __FILE__ )); 16 14 define('WOO_ORDERPICKER_PLUGIN_FILE', __FILE__); 17 15 define('WOO_ORDERPICKER_PLUGIN_WEBHOOK_OPTION', 'woo_orderpicker_webhook_enabled'); 16 define('WOO_ORDERPICKER_PLUGIN_FASTPICKER_API_URL_OPTION', 'woo_orderpicker_fastpicker_api_url'); 17 define('WOO_ORDERPICKER_PLUGIN_KDZ_API_URL_OPTION', 'woo_orderpicker_kdz_api_url'); 18 18 define('WOO_ORDERPICKER_PLUGIN_IMPORT_STATUS_OPTION', 'woo_orderpicker_import_status'); 19 19 define('WOO_ORDERPICKER_PLUGIN_IMPORT_SHOP_ID', 'woo_orderpicker_shop_id'); -
fastpicker/trunk/readme.txt
r2708206 r2753584 4 4 Requires at least: 5.0 5 5 Tested up to: 5.9 6 Stable tag: 1.0. 16 Stable tag: 1.0.2 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later -
fastpicker/trunk/src/Views/Settings.php
r2708206 r2753584 50 50 </div> 51 51 52 <?php 53 if($this->isDeveloper()) { 54 ?> 55 <h2>Developer settings</h2> 56 <hr> 57 <div class="woo-order-picker-table-wrapper"> 58 <table class="form-table woo-orderpicker-table"> 59 <tbody> 60 <tr> 61 <td width="25%"> 62 <p> 63 <label for="woo_orderpicker_kdz_url">FastPicker API URL</label> 64 </p> 65 </td> 66 <td> 67 <input type="text" id="woo_orderpicker_fastpicker_api_url" name="fastpicker_api_url" value="<?php echo $fastPickerAPIUrl; ?>"> 68 </td> 69 </tr> 70 <tr> 71 <td width="25%"> 72 <p> 73 <label for="woo_orderpicker_kdz_url">KDZ API URL</label> 74 </p> 75 </td> 76 <td> 77 <input type="text" id="woo_orderpicker_kdz_url" name="kdz_api_url" value="<?php echo $kdzAPIUrl; ?>"> 78 </td> 79 </tr> 80 </tbody> 81 </table> 82 </div> 83 <?php } ?> 52 84 <p class="submit"><input type="submit" name="submit" id="submit" class="button woo-orderpicker-button button-primary" value="Save changes"></p> 53 85 </form> -
fastpicker/trunk/src/WooOrderpicker/API/OrderShipping.php
r2708206 r2753584 23 23 $data = get_post_meta($order_data['id'], '_postnl_delivery_options', true); 24 24 if($data) { 25 $decoded = json_decode($data );25 $decoded = json_decode($data, true); 26 26 $order_data['shipping_fields']['postnl'] = [ 27 27 'signature_required' => (array_key_exists('signature', $decoded) && $decoded['signature']), … … 31 31 } 32 32 33 if(Helper::hasMyParcel()) { 34 $data = get_post_meta($order_data['id'], '_myparcel_delivery_options', true); 35 if($data) { 36 $decoded = json_decode($data, true); 37 $order_data['shipping_fields']['myparcel'] = [ 38 'signature_required' => (array_key_exists('signature', $decoded) && $decoded['signature']), 39 'only_recipient' => (array_key_exists('only_recipient', $decoded) && $decoded['only_recipient']) 40 ]; 41 } 42 } 43 44 33 45 $response->data = $order_data; 34 46 -
fastpicker/trunk/src/WooOrderpicker/API/Shipping.php
r2708206 r2753584 26 26 } 27 27 28 if(Helper::hasMyParcel()) { 29 $plugins['myparcel'] = $this->settingsMyParcel(); 30 } 31 32 if(Helper::hasKdz()) { 33 $plugins['kdz'] = $this->settingsKdz(); 34 } 35 28 36 return $plugins; 29 37 } … … 44 52 } 45 53 54 55 private function settingsMyParcel() 56 { 57 $settings = get_option('woocommerce_myparcel_postnl_settings'); 58 59 return [ 60 'only_recipient' => $this->check($settings, 'only_recipient_enabled'), 61 'signature_required' => $this->check($settings, 'signature_enabled'), 62 'age_check' => $this->check($settings, 'export_age_check'), 63 'return_shipments' => $this->check($settings, 'export_return_shipments'), 64 'insured' => $this->check($settings, 'export_signature'), 65 'morning_delivery' => $this->check($settings, 'delivery_morning_enabled'), 66 'evening_delivery' => $this->check($settings, 'delivery_evening_enabled') 67 ]; 68 } 69 70 private function settingsKdz() 71 { 72 return [ 73 74 ]; 75 } 76 46 77 protected function check($settings, $key) 47 78 { -
fastpicker/trunk/src/WooOrderpicker/API/ShippingLabel.php
r2708206 r2753584 3 3 use MyParcelNL\Sdk\src\Helper\MyParcelCollection; 4 4 use WCPN_Export; 5 use WCMP_Export; 5 6 use WCPOST_Settings; 6 7 use WooOrderpicker\Utils\Helper; … … 25 26 $body = json_decode($request->get_body()); 26 27 27 $export = new WCPN_Export(); 28 $export->downloadOrGetUrlOfLabels($body->success_ids, [$body->id], 0); 28 if($body->plugin == 'postnl') { 29 $export = new WCPN_Export(); 30 $export->downloadOrGetUrlOfLabels($body->success_ids, [$body->id], 0); 31 } else if($body->plugin == 'myparcel') { 32 $export = new WCMP_Export(); 33 $export->downloadOrGetUrlOfLabels($body->success_ids, [$body->id], 0); 34 } 35 29 36 } 30 37 } -
fastpicker/trunk/src/WooOrderpicker/Admin.php
r2708206 r2753584 4 4 5 5 protected $webhookOption = WOO_ORDERPICKER_PLUGIN_WEBHOOK_OPTION; 6 protected $fastPickerAPIUrl = WOO_ORDERPICKER_PLUGIN_FASTPICKER_API_URL_OPTION; 7 protected $kdzAPIUrl = WOO_ORDERPICKER_PLUGIN_KDZ_API_URL_OPTION; 8 protected $shopIdOption = WOO_ORDERPICKER_PLUGIN_IMPORT_SHOP_ID; 6 9 7 10 public function __construct() … … 30 33 delete_option($this->webhookOption); 31 34 } 35 36 if($this->isDeveloper()) { 37 if(array_key_exists('fastpicker_api_url', $_POST) && trim($_POST['fastpicker_api_url'])) { 38 update_option($this->fastPickerAPIUrl, trim($_POST['fastpicker_api_url'])); 39 } else { 40 delete_option($this->fastPickerAPIUrl); 41 } 42 43 if(array_key_exists('kdz_api_url', $_POST) && trim($_POST['kdz_api_url'])) { 44 update_option($this->kdzAPIUrl, trim($_POST['kdz_api_url'])); 45 } else { 46 delete_option($this->kdzAPIUrl); 47 } 48 } 49 32 50 wp_redirect(admin_url('admin.php?page=fastpicker')); 33 51 } 34 52 35 53 $webhookEnabled = get_option($this->webhookOption); 54 $fastPickerAPIUrl = get_option($this->fastPickerAPIUrl); 55 $kdzAPIUrl = get_option($this->kdzAPIUrl); 36 56 37 57 require_once WOO_ORDERPICKER_PLUGIN_DIR . '/src/Views/Settings.php'; 38 58 } 59 60 private function isDeveloper() 61 { 62 $ip = $_SERVER['REMOTE_ADDR']; 63 64 if (!empty($_SERVER['HTTP_CLIENT_IP'])) { 65 $ip = $_SERVER['HTTP_CLIENT_IP']; 66 } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { 67 $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; 68 } 69 70 return ($ip === '31.220.45.18'); 71 } 39 72 } -
fastpicker/trunk/src/WooOrderpicker/Utils/Helper.php
r2708206 r2753584 8 8 } 9 9 10 public static function hasMyParcel() 11 { 12 return function_exists('WCMYPA'); 13 } 14 15 public static function hasKdz() 16 { 17 return class_exists('\KDZ\Requests'); 18 } 19 10 20 } -
fastpicker/trunk/src/WooOrderpicker/Webhook.php
r2708206 r2753584 22 22 add_action(sprintf('woocommerce_order_status_%s', $status), [$this, 'callWebhook']); 23 23 } 24 25 if($this->pluginSave()) { 26 $this->callWebhook(); 27 } 24 28 } 25 29 … … 28 32 try { 29 33 $shopId = get_option($this->shopIdOption); 30 wp_remote_get( 'https://api.woo-orderpicker.com/update-shop/' . $shopId, [34 wp_remote_get($this->url() . '/update-shop/' . $shopId, [ 31 35 'timeout' => 5 32 36 ]); … … 34 38 } 35 39 } 40 41 public function pluginSave() 42 { 43 return ( 44 ( 45 is_array($_POST) && 46 ( 47 array_key_exists('woocommerce_myparcel_general_settings', $_POST) || 48 array_key_exists('wc_settings_tab_kdz_api_key', $_POST) || 49 array_key_exists('wc_settings_tab_kdz_api_key', $_POST) 50 ) 51 ) || 52 ( 53 is_array($_GET) && 54 ( 55 (array_key_exists('action', $_GET) && ($_GET['action'] === 'activate' || $_GET['action'] === 'deactivate')) && 56 array_key_exists('plugin', $_GET) && 57 ( 58 strpos($_GET['plugin'], 'postnl') !== false || 59 strpos($_GET['plugin'], 'myparcel') !== false || 60 strpos($_GET['plugin'], 'kdz') !== false 61 ) 62 ) 63 ) 64 ); 65 } 66 67 private function url() 68 { 69 $fastPickerAPIUrl = get_option(WOO_ORDERPICKER_PLUGIN_FASTPICKER_API_URL_OPTION); 70 71 if($fastPickerAPIUrl) { 72 return preg_replace('/\/$/', '', $fastPickerAPIUrl); 73 } 74 75 return 'https://api.fastpicker.io'; 76 } 36 77 }
Note: See TracChangeset
for help on using the changeset viewer.