'; $o .= '

Sorry, you are not allowed to access this page!

'; $o .= ''; wp_die( $o, 403 ); } global $wpdb; $table_name_commission = $wpdb->prefix . 'zacctmgr_acm_commissions_mapping'; $order = wc_get_order( $_GET['edit'] ); $account_manager = get_post_meta( $order->get_id(), '_account_manager', true ); $current_commission = (float) str_replace( ',', '', get_post_meta( $order->get_id(), '_commission', true ) ); $customer = $order->get_user(); $order_timestamp = $order->get_date_created()->date( 'Y-m-d H:i:s' ); $user_query = new WP_User_Query( array( 'search' => $account_manager, 'search_columns' => array( 'display_name' ), 'number' => 1 ) ); $results = $user_query->get_results(); $manager = $results[0]; $allowed_statuses = zacctmgr_get_allowed_wc_statuses(); $manager_commission_rate_query = $wpdb->get_results( "SELECT * FROM $table_name_commission WHERE manager_id=$manager->ID AND customer_id IS NULL AND timestamp <= '$order_timestamp' ORDER BY timestamp DESC LIMIT 1;" ); if ( count( $manager_commission_rate_query ) != 0 ) { if ( $manager_commission_rate_query[0]->no_commission == 1 ) { return 0; } if ( $manager_commission_rate_query[0]->order_level == 1 ) { $commission_rate = $manager_commission_rate_query[0]; } if ( $manager_commission_rate_query[0]->customer_account_level == 1 ) { $customer_commission_rate_query = $wpdb->get_results( "SELECT * FROM $table_name_commission WHERE manager_id=$manager->ID AND customer_id=$customer->ID AND customer_account_level=1 AND timestamp <= '$order_timestamp' ORDER BY timestamp DESC LIMIT 1;" ); if ( count( $customer_commission_rate_query ) != 0 ) { if ( $customer_commission_rate_query[0]->order_level == 0 ) { $commission_rate = $customer_commission_rate_query[0]; } else { $manager_customer_account_level_commission_rate_query = $wpdb->get_results( "SELECT * FROM $table_name_commission WHERE manager_id=$manager->ID AND customer_id IS NULL AND customer_account_level=1 AND timestamp <= '$order_timestamp' ORDER BY timestamp DESC LIMIT 1;" ); if ( count( $manager_customer_account_level_commission_rate_query ) != 0 ) { $commission_rate = $manager_customer_account_level_commission_rate_query[0]; } } } else { $manager_customer_account_level_commission_rate_query = $wpdb->get_results( "SELECT * FROM $table_name_commission WHERE manager_id=$manager->ID AND customer_id IS NULL AND customer_account_level=1 AND timestamp <= '$order_timestamp' ORDER BY timestamp DESC LIMIT 1;" ); if ( count( $manager_customer_account_level_commission_rate_query ) != 0 ) { $commission_rate = $manager_customer_account_level_commission_rate_query[0]; } } } } else { $new_commission = $existing_commission = 0; } if ( $commission_rate->no_commission == 1 ) { $new_commission = $existing_commission = 0; } else { $orders = get_posts( array( 'numberposts' => $commission_rate->new_order_commission_limit, 'meta_key' => '_customer_user', 'meta_value' => $customer->ID, 'post_type' => wc_get_order_types(), 'post_status' => $allowed_statuses, 'orderby' => 'post_date', 'order' => 'ASC' ) ); if ( $commission_rate->new_order_commission_limit != 0 ) { $isNew = false; if ( count( $orders ) > 0 ) { foreach ( $orders as $item ) { if ( $order->get_id() == $item->ID ) { $isNew = true; break; } } } } else { $isNew = false; } if ( $isNew ) { $order_new_commission_type = get_post_meta( $order->get_id(), '_new_commission_type', true ); if ( $order_new_commission_type != "" ) { if ( $order_new_commission_type == 1 ) { $new_commission = $current_commission; $existing_commission = 0.00; } else { $existing_commission = $current_commission; $new_commission = 0.00; } } else { $new_commission = $current_commission; $existing_commission = 0.00; } } else { $order_new_commission_type = get_post_meta( $order->get_id(), '_new_commission_type', true ); if ( $order_new_commission_type != "" ) { if ( $order_new_commission_type == 1 ) { $new_commission = $current_commission; $existing_commission = 0.00; } else { $existing_commission = $current_commission; $new_commission = 0.00; } } else { $existing_commission = $current_commission; $new_commission = 0.00; } } } $current_new_commission = $new_commission; $current_existing_commission = $existing_commission; $account_managers = zacctmgr_get_em_users(); ?>

Edit Order Commission


Edit Order Commission




init_address_fields(); ?>

get_order_number() ) ); ?>

get_payment_method(); $meta_list = array(); if ( $payment_method ) { /* translators: %s: payment method */ $payment_method_string = sprintf( __( 'Payment via %s', 'woocommerce' ), esc_html( $payment_method ) ); $meta_list[] = $payment_method_string; } if ( $order->get_date_paid() ) { /* translators: 1: date 2: time */ $meta_list[] = sprintf( __( 'Paid on %1$s @ %2$s', 'woocommerce' ), wc_format_datetime( $order->get_date_paid() ), wc_format_datetime( $order->get_date_paid(), get_option( 'time_format' ) ) ); } if ( $ip_address = $order->get_customer_ip_address() ) { /* translators: %s: IP address */ $meta_list[] = sprintf( __( 'Customer IP: %s', 'woocommerce' ), '' . esc_html( $ip_address ) . '' ); } echo wp_kses_post( implode( '. ', $meta_list ) ); ?>

@ ‎ :

get_user_id() ) { $user_id = absint( $order->get_user_id() ); $user = get_user_by( 'id', $user_id ); /* translators: 1: user display name 2: user ID 3: user email */ $user_string = sprintf( esc_html__( '%1$s (#%2$s – %3$s)', 'woocommerce' ), $user->display_name, absint( $user->ID ), $user->user_email ); } else { $user_string = sprintf( esc_html__( '%1$s (#%2$s – %3$s)', 'woocommerce' ), 'Guest', '', $order->get_billing_email() ); } ?>

get_formatted_billing_address() ) { echo '

' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '

'; } else { echo '

' . __( 'Address:', 'woocommerce' ) . ' ' . __( 'No billing address set.', 'woocommerce' ) . '

'; } ?>

get_formatted_shipping_address() ) { echo '

' . wp_kses( $order->get_formatted_shipping_address(), array( 'br' => array() ) ) . '

'; } else { echo '

' . __( 'Address:', 'woocommerce' ) . ' ' . __( 'No shipping address set.', 'woocommerce' ) . '

'; } ?>
get_items( apply_filters( 'woocommerce_admin_order_item_types', 'line_item' ) ); $discounts = $order->get_items( 'discount' ); $line_items_fee = $order->get_items( 'fee' ); $line_items_shipping = $order->get_items( 'shipping' ); if ( wc_tax_enabled() ) { $order_taxes = $order->get_taxes(); $tax_classes = WC_Tax::get_tax_classes(); $classes_options = wc_get_product_tax_class_options(); $show_tax_columns = count( $order_taxes ) === 1; } ?>
$tax_item ) : $tax_class = wc_get_tax_class_by_tax_id( $tax_item['rate_id'] ); $tax_class_name = isset( $classes_options[ $tax_class ] ) ? $classes_options[ $tax_class ] : __( 'Tax', 'woocommerce' ); $column_label = ! empty( $tax_item['label'] ) ? $tax_item['label'] : __( 'Tax', 'woocommerce' ); /* translators: %1$s: tax item name %2$s: tax class name */ $column_tip = sprintf( esc_html__( '%1$s (%2$s)', 'woocommerce' ), $tax_item['name'], $tax_class_name ); ?> $item ) { $product = $item->get_product(); $product_link = $product ? admin_url( 'post.php?post=' . $item->get_product_id() . '&action=edit' ) : ''; $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : ''; $row_class = apply_filters( 'woocommerce_admin_html_order_item_class', ! empty( $class ) ? $class : '', $item, $order ); ?> get_taxes() ) && wc_tax_enabled() ) { foreach ( $order_taxes as $tax_item ) { $tax_item_id = $tax_item->get_rate_id(); $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : ''; $tax_item_subtotal = isset( $tax_data['subtotal'][ $tax_item_id ] ) ? $tax_data['subtotal'][ $tax_item_id ] : ''; ?> shipping() ? WC()->shipping->load_shipping_methods() : array(); foreach ( $line_items_shipping as $item_id => $item ) { ?> get_taxes() ) && wc_tax_enabled() ) { foreach ( $order_taxes as $tax_item ) { $tax_item_id = $tax_item->get_rate_id(); $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : ''; ?> $item ) { ?> get_taxes() ) && wc_tax_enabled() ) { foreach ( $order_taxes as $tax_item ) { $tax_item_id = $tax_item->get_rate_id(); $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? $tax_data['total'][ $tax_item_id ] : ''; ?> get_refunds(); if ( $refunds ) { foreach ( $refunds as $refund ) { $who_refunded = new WP_User( $refund->get_refunded_by() ); ?> get_id() ); ?>
 
' . wp_kses_post( $thumbnail ) . ''; ?> ' . wp_kses_post( $item->get_name() ) . '' : '
' . wp_kses_post( $item->get_name() ) . '
'; if ( $product && $product->get_sku() ) { echo '
' . esc_html__( 'SKU:', 'woocommerce' ) . ' ' . esc_html( $product->get_sku() ) . '
'; } if ( $item->get_variation_id() ) { echo '
' . esc_html__( 'Variation ID:', 'woocommerce' ) . ' '; if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) { echo esc_html( $item->get_variation_id() ); } else { /* translators: %s: variation id */ printf( esc_html__( '%s (No longer exists)', 'woocommerce' ), $item->get_variation_id() ); } echo '
'; } ?>
get_formatted_meta_data( '' ) ) : ?> $meta ) : if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) { continue; } ?>
display_key ); ?>: display_value ) ); ?>
get_item_total( $item, false, true ), array( 'currency' => $order->get_currency() ) ); if ( $item->get_subtotal() !== $item->get_total() ) { echo '-' . wc_price( wc_format_decimal( $order->get_item_subtotal( $item, false, false ) - $order->get_item_total( $item, false, false ), '' ), array( 'currency' => $order->get_currency() ) ) . ''; } ?>
× ' . esc_html( $item->get_quantity() ); if ( $refunded_qty = $order->get_qty_refunded_for_item( $item_id ) ) { echo '-' . ( $refunded_qty * - 1 ) . ''; } ?>
get_total(), array( 'currency' => $order->get_currency() ) ); if ( $item->get_subtotal() !== $item->get_total() ) { echo '-' . wc_price( wc_format_decimal( $item->get_subtotal() - $item->get_total(), '' ), array( 'currency' => $order->get_currency() ) ) . ''; } if ( $refunded = $order->get_total_refunded_for_item( $item_id ) ) { echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; } ?>
$order->get_currency() ) ); } else { echo '–'; } if ( $item->get_subtotal() !== $item->get_total() ) { if ( '' === $tax_item_total ) { echo ''; } else { echo '-' . wc_price( wc_round_tax_total( $tax_item_subtotal - $tax_item_total ), array( 'currency' => $order->get_currency() ) ) . ''; } } if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id ) ) { echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; } ?>
get_name() ? $item->get_name() : __( 'Shipping', 'woocommerce' ) ); ?>
get_formatted_meta_data( '' ) ) : ?> $meta ) : if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) { continue; } ?>
display_key ); ?>: display_value ) ); ?>
   
get_total(), array( 'currency' => $order->get_currency() ) ); $refunded = $order->get_total_refunded_for_item( $item_id, 'shipping' ); if ( $refunded ) { echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; } ?>
$order->get_currency() ) ) : '–'; $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'shipping' ); if ( $refunded ) { echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; } ?>
get_name() ? $item->get_name() : __( 'Fee', 'woocommerce' ) ); ?>
   
get_total(), array( 'currency' => $order->get_currency() ) ); if ( $refunded = $order->get_total_refunded_for_item( $item_id, 'fee' ) ) { echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; } ?>
$order->get_currency() ) ) : '–'; if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'fee' ) ) { echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; } ?>
exists() ) { printf( /* translators: 1: refund id 2: refund date 3: username */ esc_html__( 'Refund #%1$s - %2$s by %3$s', 'woocommerce' ), esc_html( $refund->get_id() ), esc_html( wc_format_datetime( $refund->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) ) ), sprintf( '%2$s', /* translators: 1: ID who refunded */ sprintf( esc_attr__( 'ID: %d', 'woocommerce' ), absint( $who_refunded->ID ) ), esc_html( $who_refunded->display_name ) ) ); } else { printf( /* translators: 1: refund id 2: refund date */ esc_html__( 'Refund #%1$s - %2$s', 'woocommerce' ), esc_html( $refund->get_id() ), esc_html( wc_format_datetime( $refund->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) ) ) ); } ?> get_reason() ) : ?>

get_reason() ); ?>

   
get_amount(), array( 'currency' => $refund->get_currency() ) ) ); ?>
get_items( 'coupon' ); if ( $coupons ) :?>
  • $item ) : $post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' LIMIT 1;", $item->get_code() ) ); $class = $order->is_editable() ? 'code editable' : 'code'; ?>
  • $post_id, 'action' => 'edit', ), admin_url( 'post.php' ) ), $item, $order ); ?> get_code() ); ?> get_code() ); ?> is_editable() ) : ?>
get_total_discount() ) : ?> get_shipping_methods() ) : ?> get_tax_totals() as $code => $tax ) : ?> get_total_refunded() ) : ?>
get_total_discount(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>
get_total_shipping_refunded(); if ( $refunded > 0 ) { echo '' . strip_tags( wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ) ) . ' ' . wc_price( $order->get_shipping_total() - $refunded, array( 'currency' => $order->get_currency() ) ) . ''; // WPCS: XSS ok. } else { echo wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. } ?>
label ); ?>: get_total_tax_refunded_by_rate_id( $tax->rate_id ); if ( $refunded > 0 ) { echo '' . strip_tags( $tax->formatted_amount ) . ' ' . wc_price( WC_Tax::round( $tax->amount, wc_get_price_decimals() ) - WC_Tax::round( $refunded, wc_get_price_decimals() ), array( 'currency' => $order->get_currency() ) ) . ''; // WPCS: XSS ok. } else { echo wp_kses_post( $tax->formatted_amount ); } ?>
: get_formatted_order_total(); // WPCS: XSS ok. ?>
: -get_total_refunded(), array( 'currency' => $order->get_currency() ) ); // WPCS: XSS ok. ?>

Audit Log

print_overview(); ?>