ID ); } else { $user = null; } $manager_data = $manager_id != 0 ? get_user_by( 'ID', $manager_id ) : null; global $wpdb; $table_name = $wpdb->prefix . 'zacctmgr_acm_commissions_mapping'; $customer_commission_rate = $wpdb->get_results( "SELECT * FROM $table_name WHERE manager_id=$manager_id AND customer_id=$user->ID AND customer_account_level=1 ORDER BY timestamp DESC LIMIT 1;" ); $manager_commission_rate = $wpdb->get_results( "SELECT * FROM $table_name WHERE manager_id=$manager_id AND order_level=1 AND customer_account_level=0 ORDER BY timestamp DESC LIMIT 1;" ); $customer_account_rate = $wpdb->get_results( "SELECT * FROM $table_name WHERE manager_id=$manager_id AND customer_id IS NULL AND customer_account_level=1 ORDER BY timestamp DESC LIMIT 1;" ); if ( count( $customer_commission_rate ) == 0 ) { if ( count( $manager_commission_rate ) != 0 ) { $commission_rate = $manager_commission_rate[0]; } else { $commission_rate = new StdClass (); $commission_rate->no_commission = 0; $commission_rate->order_level = 1; $commission_rate->customer_account_level = 0; $commission_rate->new_order_commission_percentage_type = 0; $commission_rate->new_order_commission_fixed_type = 1; $commission_rate->new_order_commission_value = 0; $commission_rate->new_order_commission_limit = 1; $commission_rate->new_order_exclude_coupon_amount = 0; $commission_rate->new_order_exclude_taxes_amount = 0; $commission_rate->new_order_exclude_shipping_costs = 0; $commission_rate->new_order_exclude_shipping_tax_amount = 0; $commission_rate->existing_order_commission_percentage_type = 0; $commission_rate->existing_order_commission_fixed_type = 1; $commission_rate->existing_order_commission_value = 0; $commission_rate->existing_order_exclude_coupon_amount = 0; $commission_rate->existing_order_exclude_taxes_amount = 0; $commission_rate->existing_order_exclude_shipping_costs = 0; $commission_rate->existing_order_exclude_shipping_tax_amount = 0; } $own_custom_commission_rate = $wpdb->get_results( "SELECT * FROM $table_name WHERE manager_id=$manager_id AND customer_account_level=1 AND customer_id IS NULL ORDER BY timestamp DESC LIMIT 1;" ); if ( count( $own_custom_commission_rate ) != 0 && $own_custom_commission_rate[0]->timestamp > $manager_commission_rate[0]->timestamp ) { $commission_rate->customer_account_level = 1; $commission_rate->order_level = 0; } } else { if ( $customer_commission_rate[0]->timestamp >= $manager_commission_rate[0]->timestamp ) { $commission_rate = $customer_commission_rate[0]; } else { if ( count( $customer_account_rate ) != 0 && $customer_account_rate[0]->timestamp >= $manager_commission_rate[0]->timestamp ) { $commission_rate = $customer_account_rate[0]; } else { $commission_rate = $manager_commission_rate[0]; } } } $new_exclude = []; if ( $commission_rate->new_order_commission_percentage_type == 1 ) { if ( $commission_rate->new_order_exclude_coupon_amount == 1 ) { array_push( $new_exclude, 'coupon' ); } if ( $commission_rate->new_order_exclude_taxes_amount == 1 ) { array_push( $new_exclude, 'tax' ); } if ( $commission_rate->new_order_exclude_shipping_costs == 1 ) { array_push( $new_exclude, 'shipping' ); } if ( $commission_rate->new_order_exclude_shipping_tax_amount == 1 ) { array_push( $new_exclude, 'shipping_tax' ); } } $existing_exclude = []; if ( $commission_rate->existing_order_commission_percentage_type == 1 ) { if ( $commission_rate->existing_order_exclude_coupon_amount == 1 ) { array_push( $existing_exclude, 'coupon' ); } if ( $commission_rate->existing_order_exclude_taxes_amount == 1 ) { array_push( $existing_exclude, 'tax' ); } if ( $commission_rate->existing_order_exclude_shipping_costs == 1 ) { array_push( $existing_exclude, 'shipping' ); } if ( $commission_rate->existing_order_exclude_shipping_tax_amount == 1 ) { array_push( $existing_exclude, 'shipping_tax' ); } } if ( $commission_rate->order_level == 1 ) { $commission_type = 'order_level'; } elseif ( $commission_rate->customer_account_level == 1 ) { $commission_type = 'customer_account_level'; } else { $commission_type = 'no_commission'; } if ( $commission_rate->customer_account_level == 1 && $commission_rate->no_commission == 1 ) { $customer_commission_type = 'no_commission'; } elseif ( $commission_rate->customer_account_level == 1 && $commission_rate->order_level == 1 ) { $customer_commission_type = 'order_level'; } elseif ( $commission_rate->customer_account_level == 1 ) { $customer_commission_type = 'customer_account_level'; } else { $customer_commission_type = 'order_level'; } $new_fixed_type = $commission_rate->new_order_commission_fixed_type; $existing_fixed_type = $commission_rate->existing_order_commission_fixed_type; $new_percentage_type = $commission_rate->new_order_commission_percentage_type; $existing_percentage_type = $commission_rate->existing_order_commission_percentage_type; $order_count = $commission_rate->new_order_commission_limit; $new_value = $commission_rate->new_order_commission_value; $existing_value = $commission_rate->existing_order_commission_value; ?>
|
customer_account_level != 1 || zacctmgr_can_edit_customer_commission( $_GET['user_id'] ) == false ) { ?>
/>
/>
/>
|
|||||||||||||||||||||||||||||||
|
customer_account_level == 1 && $manager_data != null && zacctmgr_can_edit_customer_commission( $_GET['user_id'] ) == true ) { ?>
';
$value1 = '';
$value2 = '';
if ( zacctmgr_can_edit_customer_commission( $_GET['user_id'] ) == true ) {
$type1 = '';
$type1 .= '';
$type2 = '';
$type2 .= '';
$style_fixed = 'style="display: block;"';
$style_percentage = 'style="display: none;"';
if ( $new_percentage_type == 1 ) {
$style_fixed = 'style="display: none;"';
$style_percentage = 'style="display: block;"';
}
$apply1 = '';
$apply1 .= ' ';
$apply1 .= ' ';
$apply1 .= 'Order Total'; $zacctmgr_commission_new_exclude_options = $new_exclude; $apply1 .= '';
foreach ( ZACCTMGR_EXCLUDE_OPTIONS as $key => $label ) {
$extra = in_array( $key, $zacctmgr_commission_new_exclude_options ) ? 'checked="checked"' : '';
$apply1 .= ' ';
$apply1 .= '';
$apply1 .= '';
$apply1 .= '';
$apply1 .= ' ';
}
$apply1 .= '';
$apply1 .= ' ';
$style_fixed = 'style="display: block;"';
$style_percentage = 'style="display: none;"';
if ( $existing_percentage_type == 1 ) {
$style_fixed = 'style="display: none;"';
$style_percentage = 'style="display: block;"';
}
$apply2 = '';
$apply2 .= 'Fixed Value Amount'; $apply1 .= '';
$apply2 .= ' ';
$apply2 .= 'Order Total'; $zacctmgr_commission_existing_exclude_options = $existing_exclude; $apply2 .= '';
foreach ( ZACCTMGR_EXCLUDE_OPTIONS as $key => $label ) {
$extra = in_array( $key, $zacctmgr_commission_existing_exclude_options ) ? 'checked="checked"' : '';
$apply2 .= ' ';
$apply2 .= '';
$apply2 .= '';
$apply2 .= '';
$apply2 .= ' ';
}
$apply2 .= '';
$apply2 .= ' ';
}
?>
Fixed Value Amount'; $apply2 .= '
|