From f633d9a0ebb09fb52e57f2b5b2d5b800e0bc9bf0 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 15 Jun 2018 14:38:35 +0100 Subject: [PATCH] Update remove item notice based on order status --- includes/admin/class-wc-admin-assets.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/includes/admin/class-wc-admin-assets.php b/includes/admin/class-wc-admin-assets.php index 577c2c8b2cf..99a30e11373 100644 --- a/includes/admin/class-wc-admin-assets.php +++ b/includes/admin/class-wc-admin-assets.php @@ -32,7 +32,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) : global $wp_scripts; $screen = get_current_screen(); - $screen_id = $screen ? $screen->id: ''; + $screen_id = $screen ? $screen->id : ''; // Register admin styles. wp_register_style( 'woocommerce_admin_menu_styles', WC()->plugin_url() . '/assets/css/menu.css', array(), WC_VERSION ); @@ -268,18 +268,23 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) : wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION ); } if ( in_array( str_replace( 'edit-', '', $screen_id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) { - $post_id = isset( $post->ID ) ? $post->ID : ''; - $currency = ''; + $post_id = isset( $post->ID ) ? $post->ID : ''; + $currency = ''; + $remove_item_notice = __( 'Are you sure you want to remove the selected items?', 'woocommerce' ); if ( $post_id && in_array( get_post_type( $post_id ), wc_get_order_types( 'order-meta-boxes' ) ) ) { $order = wc_get_order( $post_id ); if ( $order ) { - $currency = $order->get_currency(); + $currency = $order->get_currency(); + + if ( ! $order->has_status( array( 'pending', 'failed', 'cancelled' ) ) ) { + $remove_item_notice = $remove_item_notice . ' ' . __( "You may need to manually restore the item's stock.", 'woocommerce' ); + } } } $params = array( - 'remove_item_notice' => __( "Are you sure you want to remove the selected items? If you have previously reduced this item's stock, or this order was submitted by a customer, you will need to manually restore the item's stock.", 'woocommerce' ), + 'remove_item_notice' => $remove_item_notice, 'i18n_select_items' => __( 'Please select some items.', 'woocommerce' ), 'i18n_do_refund' => __( 'Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce' ), 'i18n_delete_refund' => __( 'Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce' ),