Plugin Directory

Changeset 3142452


Ignore:
Timestamp:
08/27/2024 06:19:37 PM (18 months ago)
Author:
routedev
Message:

add new woocommerce column hooks

Location:
routeapp/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • routeapp/trunk/admin/class-routeapp-order-recover.php

    r3103716 r3142452  
    103103          'limit' => $batchSize,
    104104          'offset' => $offset,
     105          'date_created' => '>=' . $recoverFrom,
    105106          'date_created' => '<=' . $recoverTo,
    106           'date_created' => '>=' . $recoverFrom,
    107107        ];
    108108
  • routeapp/trunk/includes/class-routeapp-woocommerce.php

    r2986944 r3142452  
    2222   public function init() {
    2323
    24       if ($this->routeapp_route_enabled_extra_columns()) {
    25          add_filter( 'manage_edit-shop_order_columns', array( $this, 'routeapp_add_order_route_columns_header' ), 20 );
    26          add_action( 'manage_shop_order_posts_custom_column',  array( $this, 'routeapp_manage_route_charge_posts_custom_column' ) );
    27          add_action( 'restrict_manage_posts', array( $this, 'routeapp_display_admin_shop_order_route_protection_filter' ) );
    28          add_action( 'pre_get_posts', array( $this, 'routeapp_process_admin_shop_order_route_protection' ) );
    29       }
    30    }
     24        if ($this->routeapp_route_enabled_extra_columns()) {
     25            add_filter( 'manage_edit-shop_order_columns', array( $this, 'routeapp_add_order_route_columns_header' ), 20 );
     26            add_action( 'manage_shop_order_posts_custom_column',  array( $this, 'routeapp_manage_route_charge_posts_custom_column' ) , 99, 2 );
     27            add_action( 'restrict_manage_posts', array( $this, 'routeapp_display_admin_shop_order_route_protection_filter' ) , 99 );
     28            add_action( 'pre_get_posts', array( $this, 'routeapp_process_admin_shop_order_route_protection' ) , 99 );
     29
     30            add_action( 'manage_woocommerce_page_wc-orders_custom_column',  array( $this, 'routeapp_manage_route_charge_posts_custom_column' ) , 99, 2 );
     31            add_action( 'manage_shop_order_custom_column',  array( $this, 'routeapp_manage_route_charge_posts_custom_column' ) , 99, 2 );
     32
     33            add_filter( 'manage_woocommerce_page_wc-orders_columns', array( $this, 'routeapp_add_order_route_columns_header' ), 20 );
     34
     35        }
     36    }
    3137
    3238    /**
     
    5662    * @return void
    5763    */
    58    public function routeapp_manage_route_charge_posts_custom_column( $column ) {
    59       global $post;
    60       $order = wc_get_order( $post->ID );
     64    public function routeapp_manage_route_charge_posts_custom_column( $column,  $orderParam ) {
     65        global $post;
    6166
    62       if (  $column === 'route_charge' ) {
    63          echo wc_price( $this->routeapp_get_route_charge_fee( $order ), array( 'currency' => $order->get_currency() ) );
    64       } else if ( $column === 'route_protection' ) {         
    65          echo $this->routeapp_order_has_route_protection_fee( $order ) ? "Yes" : "No";
    66       }
    67    }
     67        // Check if $orderParam is set and not null
     68        if ( isset( $orderParam ) && ! is_null( $orderParam ) ) {
     69            $order = $orderParam; // Get the order using $orderParam if it's valid
     70        } else {
     71            $order = wc_get_order( $post->ID ); // Fallback to global $post if $orderParam is not set
     72        }
     73
     74        if (  $column === 'route_charge' ) {
     75            echo wc_price( $this->routeapp_get_route_charge_fee( $order ), array( 'currency' => $order->get_currency() ) );
     76        } else if ( $column === 'route_protection' ) {
     77            echo $this->routeapp_order_has_route_protection_fee( $order ) ? "Yes" : "No";
     78        }
     79    }
    6880
    6981    /**
     
    101113    */
    102114   public function routeapp_order_has_route_protection_fee( $order ) {
    103       $route_protection = get_post_meta($order->get_id(), '_routeapp_route_protection', true);
     115       $route_protection = "0";
     116       if ( class_exists('Automattic\WooCommerce\Utilities\OrderUtil')
     117         && OrderUtil::custom_orders_table_usage_is_enabled() ) {
     118           // HPOS usage is enabled.
     119           $route_protection = $order->get_meta('_routeapp_route_protection');
     120       } else {
     121           // Traditional CPT-based orders are in use.
     122           $route_protection = get_post_meta($order->get_id(), '_routeapp_route_protection', true);
     123       }
     124       
    104125      return $route_protection === "1";
    105126   }
  • routeapp/trunk/public/class-routeapp-public.php

    r2980248 r3142452  
    777777                    $acceptedCanceledStatuses = get_option('routeapp_cancel_order_statuses') ? get_option('routeapp_cancel_order_statuses') : [];
    778778
     779
     780                    foreach ($order->get_items('fee') as $fee) {
     781                        if ($fee->get_name() === $this->routeapp_get_insurance_label()) {
     782                            $insurance_selected = true;
     783                            $insurance_amount = $fee->get_amount();
     784                            if ( class_exists('Automattic\WooCommerce\Utilities\OrderUtil')
     785                              && OrderUtil::custom_orders_table_usage_is_enabled() ) {
     786                                // HPOS usage is enabled.
     787                                $order->update_meta_data('_routeapp_route_charge', $insurance_amount );
     788                                $order->update_meta_data('_routeapp_route_protection', $insurance_selected);
     789                                $order->save();
     790                            } else {
     791                                // Traditional CPT-based orders are in use.
     792                                update_post_meta( $order->get_id(), '_routeapp_route_charge', $insurance_amount );
     793                                update_post_meta( $order->get_id(), '_routeapp_route_protection', $insurance_selected );
     794                            }
     795                        }
     796                    }
     797                   
    779798                    if ( class_exists('Automattic\WooCommerce\Utilities\OrderUtil')
    780799                        && OrderUtil::custom_orders_table_usage_is_enabled() ) {
  • routeapp/trunk/public/js/routeapp-order-sync.js

    r3103711 r3142452  
    8080                        recoverTo = response.data.recoverTo;
    8181                        waitTime = response.data.waitTime;
    82 
     82                        processedCount = 0;
     83                        offset = 0;
     84                       
    8385                        $('#message').html('<p> Orders processed: ' + totalOrders + '/' + processedCount + '</p>');
    8486
  • routeapp/trunk/readme.txt

    r3104227 r3142452  
    66Requires at least: 4.0
    77Tested up to: 6.4.1
    8 Stable tag: 2.2.18
     8Stable tag: 2.2.20
    99Requires PHP: 5.6
    1010License: GPLv2 or later
     
    106106
    107107== Changelog ==
     108= 2.2.20 =
     109* Fix route information columns, display correct information
     110
     111= 2.2.19 =
     112* Minor update on code format
     113
    108114= 2.2.18 =
    109115* Update shipping tracking status for shipping providers
  • routeapp/trunk/routeapp.php

    r3104227 r3142452  
    1010 * Plugin URI:        https://route.com/for-merchants/
    1111 * Description:       Route allows shoppers to insure their orders with one-click during checkout, adding a layer of 3rd party trust while improving the customer shopping experience.
    12  * Version:           2.2.18
     12 * Version:           2.2.20
    1313 * Author:            Route
    1414 * Author URI:        https://route.com/
     
    2626 * Currently plugin version.
    2727 */
    28 define( 'ROUTEAPP_VERSION', '2.2.18' );
     28define( 'ROUTEAPP_VERSION', '2.2.20' );
    2929
    3030/**
Note: See TracChangeset for help on using the changeset viewer.