Plugin Directory

Changeset 3230450


Ignore:
Timestamp:
01/28/2025 11:43:32 AM (14 months ago)
Author:
hfdepost
Message:

Performance Improvement

Location:
hfd-epost-integration/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • hfd-epost-integration/trunk/class/App.php

    r3228676 r3230450  
    6666        add_filter( 'admin_init', array( $this, 'flushRewriteUrls' ) );
    6767       
     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       
    6871        //add wordpress ron for auto sync
    6972        add_filter( 'cron_schedules', array( $this, 'hfdAutoSyncOrderCron' ) );
     
    7578            wp_schedule_event( time(), 'hfd_auto_sync', 'hfd_schedule_auto_sync' );
    7679        }
    77 
    78         //update plugin settings if its not saved
    79         add_action( 'plugins_loaded', array( $this, 'hfdUpdatePluginsOptions' ) );
    80        
     80               
    8181        //action for gutenberg
    8282        if( $this->is_block_checkout() && !is_admin() ){
     
    9090        add_action( 'wp_ajax_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) );
    9191        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    }
    93127   
    94128    public function is_block_checkout(){
     
    113147        $hfd_epost_service_url = get_option( 'betanet_epost_service_url' );
    114148        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        } 
    117151        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}' );
    119153        }
    120154        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' );
    122156        }
    123157        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}' );
    125159        }
    126160        if( empty( $hfd_order_auto_sync ) ){
     
    132166       
    133167        //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                       
    137171            update_option( 'betanet_epost_service_url', $hfd_epost_service_url );
    138172        }
    139173       
    140174        $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 );
    143177           
    144178            update_option( 'betanet_epost_hfd_service_url', $betanet_epost_hfd_service_url );
    145179        }
    146180       
    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 );
    149183           
    150184            update_option( 'betanet_epost_hfd_track_shipment_url', $track_shipment_url );
    151185        }
    152186       
    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 );
    155189           
    156190            update_option( 'betanet_epost_hfd_cancel_shipment_url', $cancel_shipment_url );
    157191        }
    158192       
    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 );
    161195           
    162196            update_option( 'betanet_epost_hfd_print_label_url', $print_label_url );
     
    165199   
    166200    public function hfdScheduleAutoSyncOrder(){
     201        $hfd_order_auto_sync = get_option( 'hfd_order_auto_sync' );
    167202        $hfd_auto_sync_time = get_option( 'hfd_auto_sync_time' );
    168203        $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 ) )
    171206            return;
    172207       
    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',
    177213            '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' ) )
    180216            ),
    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 );
    189219       
    190220        if( $orderIds ){
  • hfd-epost-integration/trunk/class/Setting.php

    r3228676 r3230450  
    3434    {
    3535        $_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',
    3737            'betanet_epost_google_api_key' => '',
    3838            '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',
    4040            'betanet_epost_hfd_shipping_method' => array(\Hfd\Woocommerce\Shipping\Epost::METHOD_ID),
    4141            'betanet_epost_hfd_sender_name' => 'default',
    4242            '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}',
    4747            'hfd_order_auto_sync' => 'no',
    4848            'hfd_sync_order_items' => 'no',
  • hfd-epost-integration/trunk/hfd-woocommerce-epost.php

    r3228676 r3230450  
    55Plugin URI:
    66Description: 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.14
     7Version: 2.15
    88Author: HFD
    99Author URI: https://www.hfd.co.il
     
    2020
    2121define( 'HFD_EPOST_PATH', dirname( __FILE__ ) );
     22define( 'HFD_EPOST_PLUGIN_FILE', plugin_basename( __FILE__ ) );
    2223define( 'HFD_EPOST_PLUGIN_DIR', basename( __DIR__ ) );
    2324define( 'HFD_EPOST_PLUGIN_URL', plugins_url( HFD_EPOST_PLUGIN_DIR ) );
  • hfd-epost-integration/trunk/readme.txt

    r3228676 r3230450  
    55Requires at least: 4.0
    66Tested up to: 6.7
    7 Stable tag: 2.14
     7Stable tag: 2.15
    88Requires PHP: 5.4
    99License: GPLv2 or later
     
    7575== Third Party API ==
    7676Google Maps - maps.googleapis.com
    77 HFD - run.hfd.co.il
     77HFD - ws.hfd.co.il
    7878
    7979== Changelog ==
     
    119119* Performance Improvement
    120120
     121= 2.15 =
     122* Performance Improvement
     123
    121124== Frequently Asked Questions ==
    122125= Why Google Maps isnt loading =
Note: See TracChangeset for help on using the changeset viewer.