From b0c2f05a6aaf7b78c58f79ee9ff77c50d9249a63 Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Wed, 26 Nov 2014 13:25:15 -0800 Subject: [PATCH 1/9] Use post type label for "Save Order" button To improve compatibility with custom order types Conflicts: includes/admin/meta-boxes/class-wc-meta-box-order-actions.php --- includes/admin/meta-boxes/class-wc-meta-box-order-actions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php b/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php index 0b585c1e2df..456265dace3 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-order-actions.php @@ -23,6 +23,7 @@ class WC_Meta_Box_Order_Actions { * Output the metabox */ public static function output( $post ) { + $order_type_object = get_post_type_object( $post->post_type ); ?> '; From e4b104d153b73b320ce75af621b50f69b1ae3e7b Mon Sep 17 00:00:00 2001 From: thenbrent Date: Tue, 7 Oct 2014 15:22:16 +1000 Subject: [PATCH 7/9] Use order type's singular label for meta box names --- includes/admin/class-wc-admin-meta-boxes.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/admin/class-wc-admin-meta-boxes.php b/includes/admin/class-wc-admin-meta-boxes.php index 4fb05081842..faa318b21e7 100644 --- a/includes/admin/class-wc-admin-meta-boxes.php +++ b/includes/admin/class-wc-admin-meta-boxes.php @@ -107,11 +107,12 @@ class WC_Admin_Meta_Boxes { // Orders foreach ( wc_get_order_types( 'order-meta-boxes' ) as $type ) { - add_meta_box( 'woocommerce-order-data', __( 'Order Data', 'woocommerce' ), 'WC_Meta_Box_Order_Data::output', $type, 'normal', 'high' ); - add_meta_box( 'woocommerce-order-items', __( 'Order Items', 'woocommerce' ), 'WC_Meta_Box_Order_Items::output', $type, 'normal', 'high' ); - add_meta_box( 'woocommerce-order-notes', __( 'Order Notes', 'woocommerce' ), 'WC_Meta_Box_Order_Notes::output', $type, 'side', 'default' ); + $order_type_object = get_post_type_object( $type ); + add_meta_box( 'woocommerce-order-data', sprintf( __( '%s Data', 'woocommerce' ), $order_type_object->labels->singular_name ), 'WC_Meta_Box_Order_Data::output', $type, 'normal', 'high' ); + add_meta_box( 'woocommerce-order-items', sprintf( __( '%s Items', 'woocommerce' ), $order_type_object->labels->singular_name ), 'WC_Meta_Box_Order_Items::output', $type, 'normal', 'high' ); + add_meta_box( 'woocommerce-order-notes', sprintf( __( '%s Notes', 'woocommerce' ), $order_type_object->labels->singular_name ), 'WC_Meta_Box_Order_Notes::output', $type, 'side', 'default' ); add_meta_box( 'woocommerce-order-downloads', __( 'Downloadable Product Permissions', 'woocommerce' ) . ' [?]', 'WC_Meta_Box_Order_Downloads::output', $type, 'normal', 'default' ); - add_meta_box( 'woocommerce-order-actions', __( 'Order Actions', 'woocommerce' ), 'WC_Meta_Box_Order_Actions::output', $type, 'side', 'high' ); + add_meta_box( 'woocommerce-order-actions', sprintf( __( '%s Actions', 'woocommerce' ), $order_type_object->labels->singular_name ), 'WC_Meta_Box_Order_Actions::output', $type, 'side', 'high' ); } // Coupons From 40de60ea3e8764a8280e155d7c600636585b61ce Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Wed, 26 Nov 2014 13:53:06 -0800 Subject: [PATCH 8/9] Give child class access to billing/shipping fields So that custom order types can extend `WC_Meta_Box_Order_Data` for their own purposes without having to redefine all the billing/shipping fields --- includes/admin/meta-boxes/class-wc-meta-box-order-data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin/meta-boxes/class-wc-meta-box-order-data.php b/includes/admin/meta-boxes/class-wc-meta-box-order-data.php index a1b131e25a2..b8d4e62667c 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-order-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-order-data.php @@ -24,14 +24,14 @@ class WC_Meta_Box_Order_Data { * * @var array */ - private static $billing_fields = array(); + protected static $billing_fields = array(); /** * Shipping fields * * @var array */ - private static $shipping_fields = array(); + protected static $shipping_fields = array(); /** * Init billing and shipping fields we display + save From 1e8f25defa35a5016f10cc53511ca47b84bde07c Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Wed, 26 Nov 2014 14:22:38 -0800 Subject: [PATCH 9/9] Use wc_get_order() not new WC_Order() Because an order might be a custom order type --- includes/class-wc-ajax.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index 238d79b0cd7..86578c2ddf6 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -1063,7 +1063,7 @@ class WC_AJAX { $order_id = absint( $_POST['order_id'] ); $rate_id = absint( $_POST['rate_id'] ); - $order = new WC_Order( $order_id ); + $order = wc_get_order( $order_id ); $data = get_post_meta( $order_id ); // Add new tax @@ -1109,7 +1109,7 @@ class WC_AJAX { wc_delete_order_item( $rate_id ); // Return HTML items - $order = new WC_Order( $order_id ); + $order = wc_get_order( $order_id ); $data = get_post_meta( $order_id ); include( 'admin/meta-boxes/views/html-order-items.php' ); @@ -1375,7 +1375,7 @@ class WC_AJAX { wc_save_order_items( $order_id, $items ); // Return HTML items - $order = new WC_Order( $order_id ); + $order = wc_get_order( $order_id ); $data = get_post_meta( $order_id ); include( 'admin/meta-boxes/views/html-order-items.php' ); @@ -1399,7 +1399,7 @@ class WC_AJAX { wc_save_order_items( $order_id, $items ); // Return HTML items - $order = new WC_Order( $order_id ); + $order = wc_get_order( $order_id ); $data = get_post_meta( $order_id ); include( 'admin/meta-boxes/views/html-order-items.php' ); } @@ -1415,7 +1415,7 @@ class WC_AJAX { // Return HTML items $order_id = absint( $_POST['order_id'] ); - $order = new WC_Order( $order_id ); + $order = wc_get_order( $order_id ); $data = get_post_meta( $order_id ); include( 'admin/meta-boxes/views/html-order-items.php' );