diff --git a/aftership-woocommerce-tracking.php b/aftership-woocommerce-tracking.php index 86f179a..1b1e411 100644 --- a/aftership-woocommerce-tracking.php +++ b/aftership-woocommerce-tracking.php @@ -3,7 +3,7 @@ * Plugin Name: AfterShip Tracking - All-In-One WooCommerce Order Tracking (Free plan available) * Plugin URI: http://aftership.com/ * Description: Track orders in one place. shipment tracking, automated notifications, order lookup, branded tracking page, delivery day prediction - * Version: 1.17.3 + * Version: 1.17.4 * Author: AfterShip * Author URI: http://aftership.com * @@ -20,7 +20,7 @@ require_once( 'woo-includes/woo-functions.php' ); -define( 'AFTERSHIP_VERSION', '1.17.3' ); +define( 'AFTERSHIP_VERSION', '1.17.4' ); define( 'AFTERSHIP_PATH', dirname( __FILE__ ) ); define( 'AFTERSHIP_ASSETS_URL', plugins_url() . '/' . basename( AFTERSHIP_PATH ) ); define( 'AFTERSHIP_SCRIPT_TAGS', 'aftership_script_tags' ); @@ -191,6 +191,8 @@ public function __construct() { // Custom AfterShip Tracking column in admin orders list. add_filter( 'manage_shop_order_posts_columns', array( $this->actions, 'shop_order_columns' ), 99 ); add_action( 'manage_shop_order_posts_custom_column', array( $this->actions, 'render_shop_order_columns' ) ); + add_filter( 'manage_woocommerce_page_wc-orders_columns', array( $this->actions, 'shop_order_columns' ), 99 ); + add_action( 'manage_woocommerce_page_wc-orders_custom_column', array( $this->actions, 'render_wc_orders_list_columns' ), 10, 2 ); $subs_version = class_exists( 'WC_Subscriptions' ) && ! empty( WC_Subscriptions::$version ) ? WC_Subscriptions::$version : null; diff --git a/includes/class-aftership-actions.php b/includes/class-aftership-actions.php index eef592a..ab14726 100644 --- a/includes/class-aftership-actions.php +++ b/includes/class-aftership-actions.php @@ -128,7 +128,7 @@ public function load_orders_page_script( $hook ) { * Add the meta box for shipment info on the order page */ public function add_meta_box() { - add_meta_box( 'woocommerce-aftership', __( 'AfterShip', 'aftership' ), array( $this, 'meta_box' ), 'shop_order', 'side', 'high' ); + add_meta_box( 'woocommerce-aftership', __( 'AfterShip', 'aftership' ), array( $this, 'meta_box' ), get_order_admin_screen(), 'side', 'high' ); } /** @@ -583,7 +583,11 @@ public function save_tracking_items( $order_id, $tracking_items ) { // Delete order trackings, $tracking_items may be [] $order->update_meta_data( '_aftership_tracking_number', isset( $tracking_items[0]['tracking_number'] ) ? $tracking_items[0]['tracking_number'] : '' ); $order->update_meta_data( '_aftership_tracking_provider_name', isset( $tracking_items[0]['slug'] ) ? $tracking_items[0]['slug'] : '' ); - $order->save_meta_data(); + if (custom_orders_table_usage_is_enabled()) { + $order->save(); + } else { + $order->save_meta_data(); + } } } @@ -1051,6 +1055,22 @@ public function render_shop_order_columns( $column ) { } } + /** + * Render AfterShip tracking in custom column on WC Orders page (when using Custom Order Tables). + * + * @param string $column_name Identifier for the custom column. + * @param \WC_Order $order Current WooCommerce order object. + * + * @return void + * @since 1.8.0 + * + */ + public function render_wc_orders_list_columns( $column_name, $order ) { + if ( 'woocommerce-automizely-aftership-tracking' === $column_name ) { + echo wp_kses_post( $this->get_automizely_aftership_tracking_column( $order->get_id() ) ); + } + } + /** * Get content for shipment tracking column. * diff --git a/readme.txt b/readme.txt index ea61888..efc6f38 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.aftership.com/ Tags: woocommerce shipping,woocommerce tracking,shipment tracking,order tracking, woocommerce,track order,dhl,ups,usps,fedex,shipping,tracking,order Requires at least: 2.9 Tested up to: 6.3 -Stable tag: 1.17.3 +Stable tag: 1.17.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/woo-includes/woo-functions.php b/woo-includes/woo-functions.php index 6318320..9093e69 100644 --- a/woo-includes/woo-functions.php +++ b/woo-includes/woo-functions.php @@ -14,6 +14,30 @@ function is_woocommerce_active() { } } +if ( ! function_exists( 'wc_order_util_method_exists' ) ) { + function wc_order_util_method_exists($method_name) { + return class_exists('Automattic\WooCommerce\Utilities\OrderUtil') && method_exists('Automattic\WooCommerce\Utilities\OrderUtil', $method_name); + } +} + +if ( ! function_exists( 'custom_orders_table_usage_is_enabled' ) ) { + function custom_orders_table_usage_is_enabled() { + if(!wc_order_util_method_exists('custom_orders_table_usage_is_enabled')) { + return false; + } + return call_user_func_array(array('Automattic\WooCommerce\Utilities\OrderUtil', 'custom_orders_table_usage_is_enabled'), array()); + } +} + +if ( ! function_exists( 'get_order_admin_screen' ) ) { + function get_order_admin_screen() { + if(!wc_order_util_method_exists('get_order_admin_screen')) { + return 'shop_order'; + } + return call_user_func_array(array('Automattic\WooCommerce\Utilities\OrderUtil', 'get_order_admin_screen'), array()); + } +} + if ( ! function_exists( 'get_order_id' ) ) { function get_order_id($order) { return (method_exists($order, 'get_id'))? $order->get_id() : $order->id;