Plugin Directory

Changeset 3148549


Ignore:
Timestamp:
09/09/2024 09:43:14 AM (19 months ago)
Author:
hfdepost
Message:

Performance Improvement

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

Legend:

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

    r3137242 r3148549  
    8080       
    8181        //action for gutenberg
    82         if( function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( get_option( 'woocommerce_checkout_page_id' ) ) && !is_admin() ){
     82        if( $this->is_block_checkout() && !is_admin() ){
    8383            add_action( 'woocommerce_after_order_object_save', array( $this, 'hfd_save_pickup_info_block' ), 11, 2 );
    84             add_action( 'wp_ajax_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData') );
    85             add_action( 'wp_ajax_nopriv_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) );
    8684        }else{
    8785            add_action( 'woocommerce_checkout_order_processed', array( $this, 'convertPickupToOrder'), 10, 3 );
    8886            add_action( 'woocommerce_new_order', array($this, 'convertPickupToOrderOptional'), 99, 2 );
    8987        }
    90     }
     88       
     89        //action for render data
     90        add_action( 'wp_ajax_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) );
     91        add_action( 'wp_ajax_nopriv_hfd_get_additional_data', array( $this, 'hfdRenderAdditionalData' ) );
     92    }
     93   
     94    public function is_block_checkout(){
     95        $checkout_page_id = get_option( 'woocommerce_checkout_page_id' );
     96        if( $checkout_page_id ){
     97            //Get post object
     98            $post = get_post( $checkout_page_id );
     99           
     100            //Check if Gutenberg (block editor) is enabled for checkout
     101            return $post && post_type_supports( $post->post_type, 'editor' );
     102        }
     103        return false;
     104    }
    91105   
    92106    public function hfdUpdatePluginsOptions(){
  • hfd-epost-integration/trunk/class/Cart/Pickup.php

    r2766592 r3148549  
    1414    public function saveSpotInfo($spotInfo)
    1515    {
    16         $session = WC()->session;
    17         $session->set('epost_spot_info', $spotInfo);
     16        if( isset( WC()->session ) ){
     17            $session = WC()->session;
     18            $session->set( 'epost_spot_info', $spotInfo );
     19        }
    1820    }
    1921
     
    2325    public function getSpotInfo()
    2426    {
    25         $spotInfo = WC()->session->get('epost_spot_info');
     27        if( isset( WC()->session ) ){
     28            $spotInfo = WC()->session->get('epost_spot_info');
    2629
    27         if (!$spotInfo || !is_array($spotInfo)) {
    28             return null;
    29         }
     30            if (!$spotInfo || !is_array($spotInfo)) {
     31                return null;
     32            }
    3033
    31         return array_map(function ($value) {
    32             return stripslashes($value);
    33         }, $spotInfo);
     34            return array_map(function ($value) {
     35                return stripslashes($value);
     36            }, $spotInfo);
     37        }
     38        return;
    3439    }
    3540
     
    3944    public function clearSpotInfo()
    4045    {
    41         WC()->session->set('epost_spot_info', null);
     46        if( isset( WC()->session ) ){
     47            WC()->session->set( 'epost_spot_info', null );
     48        }
     49        return;
    4250    }
    4351
     
    4957        $shippingItems = $order->get_shipping_methods();
    5058
    51         if (!count($shippingItems)) {
     59        if( !count( $shippingItems ) ){
    5260            return;
    5361        }
    5462
    5563        /* @var \WC_Order_Item_Shipping $shippingItem */
    56         foreach ($shippingItems as $shippingItem) {
     64        foreach( $shippingItems as $shippingItem ){
    5765            $shippingItem->get_formatted_meta_data();
    5866            $methodId = \Hfd\Woocommerce\Shipping\Epost::METHOD_ID;
    59             if (substr($shippingItem->get_method_id(), 0, strlen($methodId)) == $methodId) {
     67            if( substr( $shippingItem->get_method_id(), 0, strlen( $methodId ) ) == $methodId ){
    6068                $spotInfo = $this->getSpotInfo();
    61                 if ($spotInfo) {
     69                if( $spotInfo ){
    6270                    // add pickup info into shipping item
    6371                    $spotInfo = serialize($spotInfo);
     
    6775            }
    6876        }
    69 
    70         $this->clearSpotInfo();
     77       
     78        //check if session set
     79        if( isset( WC()->session ) ){
     80            $this->clearSpotInfo();
     81        }
    7182    }
    7283}
  • hfd-epost-integration/trunk/class/Helper/Hfd/Api.php

    r3097702 r3148549  
    9999        $pParam = apply_filters( 'hfd_before_sync', $pParam );
    100100       
    101         $url = 'https://ws.hfd.co.il/RunCom.WebAPI/api/v1/shipments/create';
     101        $url = 'https://api.hfd.co.il/rest/v2/shipments/create';
    102102       
    103103        $result = array(
     
    296296            return $order->get_total();
    297297        }
    298         return '';
     298        return 0;
    299299    }
    300300   
  • hfd-epost-integration/trunk/hfd-woocommerce-epost.php

    r3137242 r3148549  
    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.8
     7Version: 2.9
    88Author: HFD
    99Author URI: https://www.hfd.co.il
  • hfd-epost-integration/trunk/readme.txt

    r3137242 r3148549  
    55Requires at least: 4.0
    66Tested up to: 6.6
    7 Stable tag: 2.8
     7Stable tag: 2.9
    88Requires PHP: 5.4
    99License: GPLv2 or later
     
    101101* Performance Improvement
    102102
     103= 2.9 =
     104* Performance Improvement
     105
    103106== Frequently Asked Questions ==
    104107= Why Google Maps isnt loading =
    105108Need to add Google map API key
    106 Need to creat Google Maps Key following the orders
     109Need to create Google Maps Key following the orders
    107110
    108111= Where I can find my Customer number =
Note: See TracChangeset for help on using the changeset viewer.