Changeset 3230450
- Timestamp:
- 01/28/2025 11:43:32 AM (14 months ago)
- Location:
- hfd-epost-integration/trunk
- Files:
-
- 4 edited
-
class/App.php (modified) (6 diffs)
-
class/Setting.php (modified) (1 diff)
-
hfd-woocommerce-epost.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hfd-epost-integration/trunk/class/App.php
r3228676 r3230450 66 66 add_filter( 'admin_init', array( $this, 'flushRewriteUrls' ) ); 67 67 68 //render wc_get_orders query 69 add_filter( 'woocommerce_order_data_store_cpt_get_orders_query', array( $this, 'hfd_handle_order_custom_query_vars' ), 10, 2 ); 70 68 71 //add wordpress ron for auto sync 69 72 add_filter( 'cron_schedules', array( $this, 'hfdAutoSyncOrderCron' ) ); … … 75 78 wp_schedule_event( time(), 'hfd_auto_sync', 'hfd_schedule_auto_sync' ); 76 79 } 77 78 //update plugin settings if its not saved 79 add_action( 'plugins_loaded', array( $this, 'hfdUpdatePluginsOptions' ) ); 80 80 81 81 //action for gutenberg 82 82 if( $this->is_block_checkout() && !is_admin() ){ … … 90 90 add_action( 'wp_ajax_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) ); 91 91 add_action( 'wp_ajax_nopriv_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) ); 92 } 92 93 //update plugin settings if its not saved 94 add_action( 'plugins_loaded', array( $this, 'hfdUpdatePluginsOptions' ) ); 95 96 //update option on plugin upgrade 97 add_action( 'upgrader_process_complete', array( $this, 'hfd_run_on_plugin_update' ), 10, 2 ); 98 } 99 100 public function hfd_run_on_plugin_update( $upgrader_object, $options ){ 101 if( $options['action'] == 'update' && $options['type'] == 'plugin' && isset( $options['plugins'] ) ){ 102 // Iterate through the plugins being updated and check if ours is there 103 if( $options['plugins'] ){ 104 foreach( $options['plugins'] as $plugin ){ 105 if( $plugin == HFD_EPOST_PLUGIN_FILE ){ 106 $this->hfdUpdatePluginsOptions(); 107 } 108 } 109 } 110 } 111 } 112 113 public function hfd_handle_order_custom_query_vars( $query, $query_vars ){ 114 if( isset( $query_vars['hfd_cron'] ) && ! empty( $query_vars['hfd_cron'] ) ){ 115 $query['meta_query'][] = array( 116 'key' => 'hfd_ship_number', 117 'compare' => 'NOT EXISTS', 118 ); 119 $query['meta_query'][] = array( 120 'key' => 'hfd_sync_flag', 121 'compare' => 'NOT EXISTS', 122 ); 123 } 124 125 return $query; 126 } 93 127 94 128 public function is_block_checkout(){ … … 113 147 $hfd_epost_service_url = get_option( 'betanet_epost_service_url' ); 114 148 if( strpos( $hfd_epost_service_url, "http://" ) !== false || empty( $hfd_epost_service_url ) ){ 115 update_option( 'betanet_epost_service_url', 'https:// run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ws_spotslist&ARGUMENTS=-Aall' );116 } 149 update_option( 'betanet_epost_service_url', 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ws_spotslist&ARGUMENTS=-Aall' ); 150 } 117 151 if( empty( $track_shipment_url ) ){ 118 update_option( 'betanet_epost_hfd_track_shipment_url', 'https:// run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_locate_random&ARGUMENTS=-A{RAND}' );152 update_option( 'betanet_epost_hfd_track_shipment_url', 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_locate_random&ARGUMENTS=-A{RAND}' ); 119 153 } 120 154 if( empty( $cancel_shipment_url ) ){ 121 update_option( 'betanet_epost_hfd_cancel_shipment_url', 'https:// run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=bitul_mishloah&ARGUMENTS=-A{shipping_number},-A,-A,-A,-N' );155 update_option( 'betanet_epost_hfd_cancel_shipment_url', 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=bitul_mishloah&ARGUMENTS=-A{shipping_number},-A,-A,-A,-N' ); 122 156 } 123 157 if( empty( $print_label_url ) ){ 124 update_option( 'betanet_epost_hfd_print_label_url', 'https:// run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}' );158 update_option( 'betanet_epost_hfd_print_label_url', 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}' ); 125 159 } 126 160 if( empty( $hfd_order_auto_sync ) ){ … … 132 166 133 167 //replace old urls to new 134 if( strpos( $hfd_epost_service_url, "uniscripts/MGrqispi.dll" ) !== false&& filter_var( $hfd_epost_service_url, FILTER_VALIDATE_URL ) == true ){135 $hfd_epost_service_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $hfd_epost_service_url );136 168 if( ( strpos( $hfd_epost_service_url, "run.hfd.co.il" ) !== false || strpos( $hfd_epost_service_url, "uniscripts/MGrqispi.dll" ) !== false ) && filter_var( $hfd_epost_service_url, FILTER_VALIDATE_URL ) == true ){ 169 $hfd_epost_service_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $hfd_epost_service_url ); 170 137 171 update_option( 'betanet_epost_service_url', $hfd_epost_service_url ); 138 172 } 139 173 140 174 $betanet_epost_hfd_service_url = get_option( 'betanet_epost_hfd_service_url' ); 141 if( strpos( $betanet_epost_hfd_service_url, "uniscripts/MGrqispi.dll" ) !== false&& filter_var( $betanet_epost_hfd_service_url, FILTER_VALIDATE_URL ) == true ){142 $betanet_epost_hfd_service_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $betanet_epost_hfd_service_url );175 if( ( strpos( $betanet_epost_hfd_service_url, "uniscripts/MGrqispi.dll" ) !== false || strpos( $betanet_epost_hfd_service_url, "run.hfd.co.il" ) !== false ) && filter_var( $betanet_epost_hfd_service_url, FILTER_VALIDATE_URL ) == true ){ 176 $betanet_epost_hfd_service_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $betanet_epost_hfd_service_url ); 143 177 144 178 update_option( 'betanet_epost_hfd_service_url', $betanet_epost_hfd_service_url ); 145 179 } 146 180 147 if( strpos( $track_shipment_url, "uniscripts/MGrqispi.dll" ) !== false&& filter_var( $track_shipment_url, FILTER_VALIDATE_URL ) == true ){148 $track_shipment_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $track_shipment_url );181 if( ( strpos( $track_shipment_url, "uniscripts/MGrqispi.dll" ) !== false || strpos( $track_shipment_url, "run.hfd.co.il" ) !== false ) && filter_var( $track_shipment_url, FILTER_VALIDATE_URL ) == true ){ 182 $track_shipment_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $track_shipment_url ); 149 183 150 184 update_option( 'betanet_epost_hfd_track_shipment_url', $track_shipment_url ); 151 185 } 152 186 153 if( strpos( $cancel_shipment_url, "uniscripts/MGrqispi.dll" ) !== false&& filter_var( $cancel_shipment_url, FILTER_VALIDATE_URL ) == true ){154 $cancel_shipment_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $cancel_shipment_url );187 if( ( strpos( $cancel_shipment_url, "uniscripts/MGrqispi.dll" ) !== false || strpos( $cancel_shipment_url, "run.hfd.co.il" ) !== false ) && filter_var( $cancel_shipment_url, FILTER_VALIDATE_URL ) == true ){ 188 $cancel_shipment_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $cancel_shipment_url ); 155 189 156 190 update_option( 'betanet_epost_hfd_cancel_shipment_url', $cancel_shipment_url ); 157 191 } 158 192 159 if( strpos( $print_label_url, "uniscripts/MGrqispi.dll" ) !== false&& filter_var( $print_label_url, FILTER_VALIDATE_URL ) == true ){160 $print_label_url = str_replace( 'uniscripts/MGrqispi.dll', 'RunCom.Server/Request.aspx', $print_label_url );193 if( ( strpos( $print_label_url, "uniscripts/MGrqispi.dll" ) !== false || strpos( $print_label_url, "run.hfd.co.il" ) !== false ) && filter_var( $print_label_url, FILTER_VALIDATE_URL ) == true ){ 194 $print_label_url = str_replace( array( 'uniscripts/MGrqispi.dll', 'run.hfd.co.il' ), array( 'RunCom.Server/Request.aspx', 'ws.hfd.co.il' ), $print_label_url ); 161 195 162 196 update_option( 'betanet_epost_hfd_print_label_url', $print_label_url ); … … 165 199 166 200 public function hfdScheduleAutoSyncOrder(){ 201 $hfd_order_auto_sync = get_option( 'hfd_order_auto_sync' ); 167 202 $hfd_auto_sync_time = get_option( 'hfd_auto_sync_time' ); 168 203 $hfd_auto_sync_status = get_option( 'hfd_auto_sync_status' ); 169 170 if( empty( $hfd_auto_sync_time ) || empty( $hfd_auto_sync_status ) )204 205 if( $hfd_order_auto_sync != "yes" || empty( $hfd_auto_sync_time ) || empty( $hfd_auto_sync_status ) ) 171 206 return; 172 207 173 $orderIds = get_posts( array( 174 'numberposts' => - 1, 175 'post_type' => array( 'shop_order' ), 176 'post_status' => array( $hfd_auto_sync_status ), 208 $args = array( 209 'limit' => -1, 210 'status' => array( $hfd_auto_sync_status ), 211 'return' => 'ids', 212 'hfd_cron' => 'yes', 177 213 'date_query' => array( 178 'after' => date( 'Y-m-d H:i:s', strtotime( '-'.$hfd_auto_sync_time.' minutes' ) ),179 'before' => date( 'Y-m-d H:i:s', time() )214 'after' => wp_date( 'Y-m-d H:i:s', strtotime( '-'.( $hfd_auto_sync_time + 10 ).' minutes' ) ), 215 'before' => wp_date( 'Y-m-d H:i:s', strtotime( '-'.$hfd_auto_sync_time.' minutes' ) ) 180 216 ), 181 'meta_query' => array( 182 array( 183 'key' => 'hfd_ship_number', 184 'compare' => 'NOT EXISTS' // this should work... 185 ) 186 ), 187 'fields' => 'ids' 188 ) ); 217 ); 218 $orderIds = wc_get_orders( $args ); 189 219 190 220 if( $orderIds ){ -
hfd-epost-integration/trunk/class/Setting.php
r3228676 r3230450 34 34 { 35 35 $_settings = array( 36 'betanet_epost_service_url' => 'https:// run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ws_spotslist&ARGUMENTS=-Aall',36 'betanet_epost_service_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ws_spotslist&ARGUMENTS=-Aall', 37 37 'betanet_epost_google_api_key' => '', 38 38 'betanet_epost_hfd_active' => 1, 39 'betanet_epost_hfd_service_url' => 'https:// run.hfd.co.il/RunCom.Server/Request.aspx',39 'betanet_epost_hfd_service_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx', 40 40 'betanet_epost_hfd_shipping_method' => array(\Hfd\Woocommerce\Shipping\Epost::METHOD_ID), 41 41 'betanet_epost_hfd_sender_name' => 'default', 42 42 'betanet_epost_hfd_customer_number' => 0, 43 'betanet_epost_hfd_print_pdf_url' => 'https:// run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{shipping_number}',44 'betanet_epost_hfd_track_shipment_url' => 'https:// run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_locate_random&ARGUMENTS=-A{RAND}',45 'betanet_epost_hfd_cancel_shipment_url' => 'https:// run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=bitul_mishloah&ARGUMENTS=-A{shipping_number},-A,-A,-A,-N',46 'betanet_epost_hfd_print_label_url' => 'https:// run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}',43 'betanet_epost_hfd_print_pdf_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{shipping_number}', 44 'betanet_epost_hfd_track_shipment_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_locate_random&ARGUMENTS=-A{RAND}', 45 'betanet_epost_hfd_cancel_shipment_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=bitul_mishloah&ARGUMENTS=-A{shipping_number},-A,-A,-A,-N', 46 'betanet_epost_hfd_print_label_url' => 'https://ws.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}', 47 47 'hfd_order_auto_sync' => 'no', 48 48 'hfd_sync_order_items' => 'no', -
hfd-epost-integration/trunk/hfd-woocommerce-epost.php
r3228676 r3230450 5 5 Plugin URI: 6 6 Description: Add shipping method of ePost, allowing the user on the checkout, to select the pickup location point from a google map popup. Also allows to synch the order to HFD API after the order is created. 7 Version: 2.1 47 Version: 2.15 8 8 Author: HFD 9 9 Author URI: https://www.hfd.co.il … … 20 20 21 21 define( 'HFD_EPOST_PATH', dirname( __FILE__ ) ); 22 define( 'HFD_EPOST_PLUGIN_FILE', plugin_basename( __FILE__ ) ); 22 23 define( 'HFD_EPOST_PLUGIN_DIR', basename( __DIR__ ) ); 23 24 define( 'HFD_EPOST_PLUGIN_URL', plugins_url( HFD_EPOST_PLUGIN_DIR ) ); -
hfd-epost-integration/trunk/readme.txt
r3228676 r3230450 5 5 Requires at least: 4.0 6 6 Tested up to: 6.7 7 Stable tag: 2.1 47 Stable tag: 2.15 8 8 Requires PHP: 5.4 9 9 License: GPLv2 or later … … 75 75 == Third Party API == 76 76 Google Maps - maps.googleapis.com 77 HFD - run.hfd.co.il77 HFD - ws.hfd.co.il 78 78 79 79 == Changelog == … … 119 119 * Performance Improvement 120 120 121 = 2.15 = 122 * Performance Improvement 123 121 124 == Frequently Asked Questions == 122 125 = Why Google Maps isnt loading =
Note: See TracChangeset
for help on using the changeset viewer.