Merge pull request #6939 from thenbrent/custom-order-tweaks-2-3

Custom order tweaks (for v2.3)
This commit is contained in:
Claudio Sanches 2014-12-11 01:06:56 -02:00
commit 4660ca5687
6 changed files with 26 additions and 30 deletions

View File

@ -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' ) . ' <span class="tips" data-tip="' . __( 'Note: Permissions for order items will automatically be granted when the order status changes to processing/completed.', 'woocommerce' ) . '">[?]</span>', '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

View File

@ -1400,18 +1400,12 @@ class WC_Admin_Post_Types {
public function restrict_manage_posts() {
global $typenow, $wp_query;
switch ( $typenow ) {
case 'product' :
$this->product_filters();
break;
case 'shop_coupon' :
$this->shop_coupon_filters();
break;
case 'shop_order' :
if ( in_array( $typenow, wc_get_order_types( 'order-meta-boxes' ) ) ) {
$this->shop_order_filters();
break;
default :
break;
} elseif ( 'product' == $typenow ) {
$this->product_filters();
} elseif( 'shop_coupon' == $typenow ) {
$this->shop_coupon_filters();
}
}
@ -1594,7 +1588,7 @@ class WC_Admin_Post_Types {
$vars['meta_value'] = wc_clean( $_GET['coupon_type'] );
}
} elseif ( 'shop_order' === $typenow ) {
} elseif ( in_array( $typenow, wc_get_order_types( 'order-meta-boxes' ) ) ) {
// Filter the orders by the posted customer.
if ( isset( $_GET['_customer_user'] ) && $_GET['_customer_user'] > 0 ) {
@ -1831,7 +1825,7 @@ class WC_Admin_Post_Types {
$post_type = get_post_type( $id );
if ( 'shop_order' == $post_type ) {
if ( in_array( $post_type, wc_get_order_types( 'order-count' ) ) ) {
// Delete count - meta doesn't work on trashed posts
$user_id = get_post_meta( $id, '_customer_user', true );
@ -1865,7 +1859,7 @@ class WC_Admin_Post_Types {
$post_type = get_post_type( $id );
if ( 'shop_order' == $post_type ) {
if ( in_array( $post_type, wc_get_order_types( 'order-count' ) ) ) {
// Delete count - meta doesn't work on trashed posts
$user_id = get_post_meta( $id, '_customer_user', true );
@ -1892,7 +1886,7 @@ class WC_Admin_Post_Types {
public function delete_order_items( $postid ) {
global $wpdb;
if ( get_post_type( $postid ) == 'shop_order' ) {
if ( in_array( get_post_type( $postid ), wc_get_order_types() ) ) {
do_action( 'woocommerce_delete_order_items', $postid );
$wpdb->query( "
@ -1948,7 +1942,7 @@ class WC_Admin_Post_Types {
public function change_insert_into_post( $strings ) {
global $post_type;
if ( in_array( $post_type, array( 'product', 'shop_order', 'shop_coupon' ) ) ) {
if ( in_array( $post_type, array( 'product', 'shop_coupon' ) ) || in_array( $post_type, wc_get_order_types() ) ) {
$obj = get_post_type_object( $post_type );
$strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'woocommerce' ), $obj->labels->singular_name );

View File

@ -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 );
?>
<ul class="order_actions submitbox">
@ -71,7 +72,7 @@ class WC_Meta_Box_Order_Actions {
}
?></div>
<input type="submit" class="button save_order button-primary tips" name="save" value="<?php _e( 'Save Order', 'woocommerce' ); ?>" data-tip="<?php _e( 'Save/update the order', 'woocommerce' ); ?>" />
<input type="submit" class="button save_order button-primary tips" name="save" value="<?php printf( __( 'Save %s', 'woocommerce' ), $order_type_object->labels->singular_name ); ?>" data-tip="<?php printf( __( 'Save/update the %s', 'woocommerce' ), $order_type_object->labels->singular_name ); ?>" />
</li>
<?php do_action( 'woocommerce_order_actions_end', $post->ID ); ?>

View File

@ -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

View File

@ -58,7 +58,7 @@ class WC_Meta_Box_Order_Notes {
}
} else {
echo '<li>' . __( 'There are no notes for this order yet.', 'woocommerce' ) . '</li>';
echo '<li>' . __( 'There are no notes yet.', 'woocommerce' ) . '</li>';
}
echo '</ul>';

View File

@ -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' );