I am creating a new woocommerce plugin that will give you a discount on discount on top of the cart page.
Now, when there are goods in the basket, the user clicks the "Apply discount" button, and when pressed, the action is launched from my custom plug-in, which will add a discount to the basket for this particular basket order.
So far this has worked perfectly, and also shows that the discount on the basket is applied. below is a screenshot

As you can see in the screenshot, the wrong number is displayed on the Order Total screen. Below is the code from my custom woocommerce plugin file.
The following action is called when the button is sent.
if(!empty($_POST['apply_discount_woo'])){
add_action('woocommerce_calculate_totals',array(&$this,'cart_order_total_action'));
}
and function code:
public function cart_order_total_action(){
if ( is_user_logged_in() ){
global $woocommerce;
global $current_user;
global $wpdb;
$u_id = $current_user->ID;
$table_name = $wpdb->prefix."woocommerce_customer_reward_ms";
$thetable2 = $wpdb->prefix . "woocommerce_customer_reward_cart_ms";
$table_name3 = $wpdb->prefix."woocommerce_customer_reward_points_log_ms";
$data = $wpdb->get_row("SELECT * from $table_name where id=$u_id");
$data2 = $wpdb->get_row("SELECT * from $thetable2");
$orders=array();
$args = array(
'numberposts' => -1,
'meta_key' => '_customer_user',
'meta_value' => $current_user->ID,
'post_type' => 'shop_order',
'post_status' => 'publish',
'tax_query'=>array(
array(
'taxonomy' =>'shop_order_status',
'field' => 'slug',
'terms' =>'on-hold'
)
)
);
$posts=get_posts($args);
$orders=wp_list_pluck( $posts, 'ID' );
$order = $orders[0];
if($data){
$user_points = $data->points;
$points_set = $data2->woo_pts_set;
print_r($woocommerce->cart->applied_coupons);
echo $woocommerce->cart->discount_cart;
echo $woocommerce->cart->get_cart_total();
$woocommerce->cart->discount_cart = $data2->woo_discount_set;
}else{
echo 'You dont have any woo points yet.!!';
}
}
}
?