Changeset 2409719
- Timestamp:
- 10/30/2020 12:10:16 PM (5 years ago)
- Location:
- hfd-integration/trunk
- Files:
-
- 6 edited
-
class/Admin.php (modified) (3 diffs)
-
class/App.php (modified) (1 diff)
-
class/Setting.php (modified) (1 diff)
-
hfd-woocommerce-epost.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
templates/admin/setting.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hfd-integration/trunk/class/Admin.php
r2393139 r2409719 62 62 $cancel_shipment_url = get_option( 'betanet_epost_hfd_cancel_shipment_url' ); 63 63 $print_label_url = get_option( 'betanet_epost_hfd_print_label_url' ); 64 $hfd_order_auto_sync = get_option( 'hfd_order_auto_sync' ); 64 65 if( empty( $track_shipment_url ) ){ 65 66 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}' ); … … 70 71 if( empty( $print_label_url ) ){ 71 72 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}' ); 73 } 74 if( empty( $hfd_order_auto_sync ) ){ 75 update_option( 'hfd_order_auto_sync', 'no' ); 72 76 } 73 77 } … … 327 331 'betanet_epost_hfd_sender_name', 328 332 'betanet_epost_hfd_customer_number', 329 'betanet_epost_hfd_debug' 333 'betanet_epost_hfd_debug', 334 'hfd_order_auto_sync', 335 'hfd_auto_sync_status', 336 'hfd_auto_sync_time' 330 337 ); 331 338 -
hfd-integration/trunk/class/App.php
r2393139 r2409719 66 66 //flush reqrite rules 67 67 add_filter( 'admin_init', array( $this, 'flushRewriteUrls' ) ); 68 } 68 69 //add wordpress ron for auto sync 70 add_filter( 'cron_schedules', array( $this, 'hfdAutoSyncOrderCron' ) ); 71 72 add_action( 'hfd_schedule_auto_sync', array( $this, 'hfdScheduleAutoSyncOrder' ) ); 73 74 // Schedule an action if it's not already scheduled 75 if( !wp_next_scheduled( 'hfd_schedule_auto_sync' ) ){ 76 wp_schedule_event( time(), 'hfd_auto_sync', 'hfd_schedule_auto_sync' ); 77 } 78 } 79 80 public function hfdScheduleAutoSyncOrder(){ 81 $hfd_auto_sync_time = get_option( 'hfd_auto_sync_time' ); 82 $hfd_auto_sync_status = get_option( 'hfd_auto_sync_status' ); 83 84 if( empty( $hfd_auto_sync_time ) || empty( $hfd_auto_sync_status ) ) 85 return; 86 87 $orderIds = get_posts( array( 88 'numberposts' => - 1, 89 'post_type' => array( 'shop_order' ), 90 'post_status' => array( $hfd_auto_sync_status ), 91 'date_query' => array( 92 'after' => date( 'Y-m-d H:i:s', strtotime( '-'.$hfd_auto_sync_time.' minutes' ) ), 93 'before' => date( 'Y-m-d H:i:s', time() ) 94 ), 95 'meta_query' => array( 96 array( 97 'key' => 'hfd_ship_number', 98 'compare' => 'NOT EXISTS' // this should work... 99 ) 100 ), 101 'fields' => 'ids' 102 ) ); 103 104 if( $orderIds ){ 105 /* @var \Hfd\Woocommerce\Helper\Hfd $hfdHelper */ 106 $hfdHelper = Container::create('Hfd\Woocommerce\Helper\Hfd'); 107 $result = $hfdHelper->sendOrders( $orderIds ); 108 $filesystem = Container::get('Hfd\Woocommerce\Filesystem'); 109 $filesystem->writeSession( serialize($result), 'sync_to_hfd' ); 110 } 111 } 112 113 public function hfdAutoSyncOrderCron( $schedules ){ 114 $hfd_auto_sync_time = get_option( 'hfd_auto_sync_time' ); 115 $hfd_order_auto_sync = get_option( 'hfd_order_auto_sync' ); 116 if( !empty( $hfd_auto_sync_time ) && $hfd_order_auto_sync == "yes" ){ 117 $schedules['hfd_auto_sync'] = array( 118 'interval' => 60, 119 'display' => sprintf( __( 'Every %s Minute', HFD_WC_EPOST ), 1 ) 120 ); 121 } 122 return $schedules; 123 } 69 124 70 125 public function flushRewriteUrls(){ -
hfd-integration/trunk/class/Setting.php
r2393139 r2409719 45 45 'betanet_epost_hfd_track_shipment_url' => 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_locate_random&ARGUMENTS=-A{RAND}', 46 46 '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', 47 'betanet_epost_hfd_print_label_url' => 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}' 47 'betanet_epost_hfd_print_label_url' => 'https://run.hfd.co.il/RunCom.Server/Request.aspx?APPNAME=run&PRGNAME=ship_print_ws&ARGUMENTS=-N{RAND}', 48 'hfd_order_auto_sync' => 'no', 48 49 ); 49 50 -
hfd-integration/trunk/hfd-woocommerce-epost.php
r2393145 r2409719 4 4 Plugin URI: 5 5 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. 6 Version: 1. 1.06 Version: 1.2.0 7 7 Author: HFD 8 8 Author URI: https://www.hfd.co.il -
hfd-integration/trunk/readme.txt
r2393145 r2409719 75 75 76 76 == Changelog == 77 = 1.2 = 78 * הוספת אפשרות לסנכרון מיידי של הזמנות ללא צורך בפעולה כל פעם 77 79 = 1.1 = 78 80 * Bug fixes -
hfd-integration/trunk/templates/admin/setting.php
r2393139 r2409719 6 6 */ 7 7 /* @var \Hfd\Woocommerce\Setting $setting */ 8 9 $order_auto_sync = $setting->get( 'hfd_order_auto_sync' ); 10 $hfd_auto_sync_status = $setting->get( 'hfd_auto_sync_status' ); 11 $hfd_auto_sync_time = $setting->get( 'hfd_auto_sync_time' ); 12 if( empty( $order_auto_sync ) ){ 13 $order_auto_sync = 'no'; 14 } 8 15 ?> 9 16 <div id="ch2pho-general" class="wrap"> … … 105 112 </td> 106 113 </tr> 114 <tr valign="top"> 115 <th scope="row"><?php _e('Order auto sync', HFD_WC_EPOST); ?></th> 116 <td> 117 <div> 118 <input type="radio" name="hfd_order_auto_sync" value="yes" <?php checked( $order_auto_sync, 'yes' ); ?> /> <?php _e( 'Yes', HFD_WC_EPOST ); ?> 119 </div> 120 <div> 121 <input type="radio" name="hfd_order_auto_sync" value="no" <?php checked( $order_auto_sync, 'no' ); ?> /> <?php _e( 'No', HFD_WC_EPOST ); ?> 122 </div> 123 </td> 124 </tr> 125 <tr valign="top"> 126 <th scope="row"><?php _e('Auto sync status', HFD_WC_EPOST); ?></th> 127 <td> 128 <select name="hfd_auto_sync_status" class="regular-text"> 129 <option value=""><?php _e( '--Select--', HFD_WC_EPOST ); ?></option> 130 <?php 131 if( function_exists( 'wc_get_order_statuses' ) ){ 132 $statuses = wc_get_order_statuses(); 133 if( $statuses ){ 134 foreach( $statuses as $statusCode => $status ){ 135 echo '<option value="'.$statusCode.'" '; 136 echo selected( $hfd_auto_sync_status, $statusCode ); 137 echo '>'.$status.'</option>'; 138 } 139 } 140 } 141 ?> 142 </select> 143 </td> 144 </tr> 145 <tr valign="top"> 146 <th scope="row"><?php _e( 'Auto sync time', HFD_WC_EPOST ); ?></th> 147 <td> 148 <select name="hfd_auto_sync_time" class="regular-text"> 149 <option value=""><?php _e( '--Select--', HFD_WC_EPOST ); ?></option> 150 <option value="15" <?php selected( $hfd_auto_sync_time, 15 ); ?>>15</option> 151 <option value="30" <?php selected( $hfd_auto_sync_time, 30 ); ?>>30</option> 152 <option value="60" <?php selected( $hfd_auto_sync_time, 60 ); ?>>60</option> 153 </select> 154 </td> 155 </tr> 107 156 </tbody> 108 157 </table>
Note: See TracChangeset
for help on using the changeset viewer.