From e39da623cf4172913ee4f9d046905f7445a634bd Mon Sep 17 00:00:00 2001 From: Mino <43281889+mino129@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:04:59 +0100 Subject: [PATCH] enhancement: making tooltips message be selected based on order status slug. changes to get_order_status_label filter (#49812) * enhancement: making tooltips message be selected based on order status. passes order object in woocommerce_get_order_status_labels filter for more personalized tooltips. * Add changefile(s) from automation for the following project(s): woocommerce * fix: change incorrect keys of order status in order_status array * remove duplicate changelog file * fix: linting issues --------- Co-authored-by: github-actions Co-authored-by: Adrian Duffell <9312929+adrianduffell@users.noreply.github.com> --- .../49812-enhancement-order-list-tooltip | 4 ++++ .../src/Internal/Admin/Orders/ListTable.php | 20 +++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 plugins/woocommerce/changelog/49812-enhancement-order-list-tooltip diff --git a/plugins/woocommerce/changelog/49812-enhancement-order-list-tooltip b/plugins/woocommerce/changelog/49812-enhancement-order-list-tooltip new file mode 100644 index 00000000000..119fcd34fa3 --- /dev/null +++ b/plugins/woocommerce/changelog/49812-enhancement-order-list-tooltip @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Tooltips message is now selected based on the order status instead of the label of the order status, which would break if the current WordPress language was not English. Also passes the order object to the woocommerce_get_order_status_labels filter to allow for more personalized tooltips. \ No newline at end of file diff --git a/plugins/woocommerce/src/Internal/Admin/Orders/ListTable.php b/plugins/woocommerce/src/Internal/Admin/Orders/ListTable.php index efb3ce365c5..daabf12f55c 100644 --- a/plugins/woocommerce/src/Internal/Admin/Orders/ListTable.php +++ b/plugins/woocommerce/src/Internal/Admin/Orders/ListTable.php @@ -1064,14 +1064,14 @@ class ListTable extends WP_List_Table { */ private function get_order_status_label( WC_Order $order ): string { $status_names = array( - 'Pending payment' => __( 'The order has been received, but no payment has been made. Pending payment orders are generally awaiting customer action.', 'woocommerce' ), - 'On hold' => __( 'The order is awaiting payment confirmation. Stock is reduced, but you need to confirm payment.', 'woocommerce' ), - 'Processing' => __( 'Payment has been received (paid), and the stock has been reduced. The order is awaiting fulfillment.', 'woocommerce' ), - 'Completed' => __( 'Order fulfilled and complete.', 'woocommerce' ), - 'Failed' => __( 'The customer’s payment failed or was declined, and no payment has been successfully made.', 'woocommerce' ), - 'Draft' => __( 'Draft orders are created when customers start the checkout process while the block version of the checkout is in place.', 'woocommerce' ), - 'Canceled' => __( 'The order was canceled by an admin or the customer.', 'woocommerce' ), - 'Refunded' => __( 'Orders are automatically put in the Refunded status when an admin or shop manager has fully refunded the order’s value after payment.', 'woocommerce' ), + 'pending' => __( 'The order has been received, but no payment has been made. Pending payment orders are generally awaiting customer action.', 'woocommerce' ), + 'on-hold' => __( 'The order is awaiting payment confirmation. Stock is reduced, but you need to confirm payment.', 'woocommerce' ), + 'processing' => __( 'Payment has been received (paid), and the stock has been reduced. The order is awaiting fulfillment.', 'woocommerce' ), + 'completed' => __( 'Order fulfilled and complete.', 'woocommerce' ), + 'failed' => __( 'The customer’s payment failed or was declined, and no payment has been successfully made.', 'woocommerce' ), + 'checkout-draft' => __( 'Draft orders are created when customers start the checkout process while the block version of the checkout is in place.', 'woocommerce' ), + 'cancelled' => __( 'The order was canceled by an admin or the customer.', 'woocommerce' ), + 'refunded' => __( 'Orders are automatically put in the Refunded status when an admin or shop manager has fully refunded the order’s value after payment.', 'woocommerce' ), ); /** @@ -1081,9 +1081,9 @@ class ListTable extends WP_List_Table { * @param WC_Order $order Current order object. * @since 9.1.0 */ - $status_names = apply_filters( 'woocommerce_get_order_status_labels', $status_names ); + $status_names = apply_filters( 'woocommerce_get_order_status_labels', $status_names, $order ); - $status_name = wc_get_order_status_name( $order->get_status() ); + $status_name = $order->get_status(); return isset( $status_names[ $status_name ] ) ? $status_names[ $status_name ] : ''; }