From eed6ca4405b0ee8a2033c3f6471a1400a4125b97 Mon Sep 17 00:00:00 2001 From: claudiosmweb Date: Sun, 20 Jul 2014 20:53:55 -0300 Subject: [PATCH] removed order totals meta box --- includes/admin/class-wc-admin-meta-boxes.php | 6 +- .../class-wc-meta-box-order-totals.php | 208 ------------------ 2 files changed, 2 insertions(+), 212 deletions(-) delete mode 100644 includes/admin/meta-boxes/class-wc-meta-box-order-totals.php diff --git a/includes/admin/class-wc-admin-meta-boxes.php b/includes/admin/class-wc-admin-meta-boxes.php index 796409ce836..b06849e5825 100644 --- a/includes/admin/class-wc-admin-meta-boxes.php +++ b/includes/admin/class-wc-admin-meta-boxes.php @@ -40,7 +40,6 @@ class WC_Admin_Meta_Boxes { * Save actions - sends out other emails. Last to show latest data. */ add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Items::save', 10, 2 ); - add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Totals::save', 20, 2 ); add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Downloads::save', 30, 2 ); add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Data::save', 40, 2 ); add_action( 'woocommerce_process_shop_order_meta', 'WC_Meta_Box_Order_Actions::save', 50, 2 ); @@ -107,7 +106,6 @@ class WC_Admin_Meta_Boxes { 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-totals', __( 'Order Totals', 'woocommerce' ), 'WC_Meta_Box_Order_Totals::output', $type, 'side', 'default' ); add_meta_box( 'woocommerce-order-notes', __( 'Order Notes', 'woocommerce' ), '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' ); @@ -175,11 +173,11 @@ class WC_Admin_Meta_Boxes { if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { return; } - + // Check the nonce if ( empty( $_POST['woocommerce_meta_nonce'] ) || ! wp_verify_nonce( $_POST['woocommerce_meta_nonce'], 'woocommerce_save_data' ) ) { return; - } + } // Check the post being saved == the $post_id to prevent triggering this call for other save_post events if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { diff --git a/includes/admin/meta-boxes/class-wc-meta-box-order-totals.php b/includes/admin/meta-boxes/class-wc-meta-box-order-totals.php deleted file mode 100644 index 500946dd6ac..00000000000 --- a/includes/admin/meta-boxes/class-wc-meta-box-order-totals.php +++ /dev/null @@ -1,208 +0,0 @@ -ID ); - - $order = $theorder; - - $data = get_post_meta( $post->ID ); - ?> - - - -
-

-
- get_results( "SELECT tax_rate_id, tax_rate_country, tax_rate_state, tax_rate_name, tax_rate_priority FROM {$wpdb->prefix}woocommerce_tax_rates ORDER BY tax_rate_name" ); - - $tax_codes = array(); - - foreach( $rates as $rate ) { - $code = array(); - - $code[] = $rate->tax_rate_country; - $code[] = $rate->tax_rate_state; - $code[] = $rate->tax_rate_name ? sanitize_title( $rate->tax_rate_name ) : 'TAX'; - $code[] = absint( $rate->tax_rate_priority ); - - $tax_codes[ $rate->tax_rate_id ] = strtoupper( implode( '-', array_filter( $code ) ) ); - } - - foreach ( $order->get_taxes() as $item_id => $item ) { - include( 'views/html-order-tax.php' ); - } - ?> -
-

[?]

-
-
- - - -

- - - - -

- $value ) { - - if ( $item_id == 'new' ) { - - foreach ( $value as $new_key => $new_value ) { - $rate_id = absint( $order_taxes_rate_id[ $item_id ][ $new_key ] ); - - if ( $rate_id ) { - $rate = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $rate_id ) ); - $label = $rate->tax_rate_name ? $rate->tax_rate_name : WC()->countries->tax_or_vat(); - $compound = $rate->tax_rate_compound ? 1 : 0; - - $code = array(); - - $code[] = $rate->tax_rate_country; - $code[] = $rate->tax_rate_state; - $code[] = $rate->tax_rate_name ? $rate->tax_rate_name : 'TAX'; - $code[] = absint( $rate->tax_rate_priority ); - $code = strtoupper( implode( '-', array_filter( $code ) ) ); - } else { - $code = ''; - $label = WC()->countries->tax_or_vat(); - } - - // Add line item - $new_id = wc_add_order_item( $post_id, array( - 'order_item_name' => wc_clean( $code ), - 'order_item_type' => 'tax' - ) ); - - // Add line item meta - if ( $new_id ) { - wc_update_order_item_meta( $new_id, 'rate_id', $rate_id ); - wc_update_order_item_meta( $new_id, 'label', $label ); - wc_update_order_item_meta( $new_id, 'compound', $compound ); - - if ( isset( $order_taxes_amount[ $item_id ][ $new_key ] ) ) { - wc_update_order_item_meta( $new_id, 'tax_amount', wc_format_decimal( $order_taxes_amount[ $item_id ][ $new_key ] ) ); - - $total_tax += wc_format_decimal( $order_taxes_amount[ $item_id ][ $new_key ] ); - } - - if ( isset( $order_taxes_shipping_amount[ $item_id ][ $new_key ] ) ) { - wc_update_order_item_meta( $new_id, 'shipping_tax_amount', wc_format_decimal( $order_taxes_shipping_amount[ $item_id ][ $new_key ] ) ); - - $total_shipping_tax += wc_format_decimal( $order_taxes_shipping_amount[ $item_id ][ $new_key ] ); - } - } - } - - } else { - - $item_id = absint( $item_id ); - $rate_id = absint( $order_taxes_rate_id[ $item_id ] ); - - if ( $rate_id ) { - $rate = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $rate_id ) ); - $label = $rate->tax_rate_name ? $rate->tax_rate_name : WC()->countries->tax_or_vat(); - $compound = $rate->tax_rate_compound ? 1 : 0; - - $code = array(); - - $code[] = $rate->tax_rate_country; - $code[] = $rate->tax_rate_state; - $code[] = $rate->tax_rate_name ? $rate->tax_rate_name : 'TAX'; - $code[] = absint( $rate->tax_rate_priority ); - $code = strtoupper( implode( '-', array_filter( $code ) ) ); - } else { - $code = ''; - $label = WC()->countries->tax_or_vat(); - } - - $wpdb->update( - $wpdb->prefix . "woocommerce_order_items", - array( 'order_item_name' => wc_clean( $code ) ), - array( 'order_item_id' => $item_id ), - array( '%s' ), - array( '%d' ) - ); - - wc_update_order_item_meta( $item_id, 'rate_id', $rate_id ); - wc_update_order_item_meta( $item_id, 'label', $label ); - wc_update_order_item_meta( $item_id, 'compound', $compound ); - - if ( isset( $order_taxes_amount[ $item_id ] ) ) { - wc_update_order_item_meta( $item_id, 'tax_amount', wc_format_decimal( $order_taxes_amount[ $item_id ] ) ); - - $total_tax += wc_format_decimal( $order_taxes_amount[ $item_id ] ); - } - - if ( isset( $order_taxes_shipping_amount[ $item_id ] ) ) { - wc_update_order_item_meta( $item_id, 'shipping_tax_amount', wc_format_decimal( $order_taxes_shipping_amount[ $item_id ] ) ); - - $total_shipping_tax += wc_format_decimal( $order_taxes_shipping_amount[ $item_id ] ); - } - } - } - } - - // Update totals - update_post_meta( $post_id, '_order_tax', wc_format_decimal( $total_tax ) ); - update_post_meta( $post_id, '_order_shipping_tax', wc_format_decimal( $total_shipping_tax ) ); - - // Delete rows - if ( isset( $_POST['delete_order_item_id'] ) ) { - $delete_ids = $_POST['delete_order_item_id']; - - foreach ( $delete_ids as $id ) - wc_delete_order_item( absint( $id ) ); - } - } -}