title: Cart Discount when applied to the cart doesn't show the correct amount in Order Total using Woocommerce in wordpress
body: <p>I have being creating a new woocommerce plugin that will provide an option to the apply discount on top of the cart page.</p>
  
  <p>Now when there are products in the cart, the user will click on the Apply Discount button and when clicked and action is triggered from my custom plugin that will add cart discount to that particular Cart Order.</p>
  
  <p>So far it works fine and also shows that cart discount applied. below is the screenshot</p>
  
  <p><img src="https://i.stack.imgur.com/fTzIn.png" alt="enter image description here"></p>
  
  <p>As you can see from the screenshot there the Order Total is showing Wrong figure calculated.
  Below is the code from my custom woocommerce plugin file.</p>
  
  <p>Following action is called when the button is submitted </p>
  
  <pre><code>if(!empty($_POST['apply_discount_woo'])){
                      add_action('woocommerce_calculate_totals',array(&amp;$this,'cart_order_total_action'));
                  }
  </code></pre>
  
  <p>and the function code:</p>
  
  <pre><code>public function cart_order_total_action(){
                  if ( is_user_logged_in() ){
                      global $woocommerce;
                      global $current_user;
                      global $wpdb;
                      $u_id = $current_user-&gt;ID;
                      $table_name = $wpdb-&gt;prefix."woocommerce_customer_reward_ms";
                      $thetable2  = $wpdb-&gt;prefix . "woocommerce_customer_reward_cart_ms";
                      $table_name3 = $wpdb-&gt;prefix."woocommerce_customer_reward_points_log_ms";
                      $data       = $wpdb-&gt;get_row("SELECT * from $table_name where id=$u_id");
                      $data2      = $wpdb-&gt;get_row("SELECT * from $thetable2");
                      /* Order Id goes here */
                      $orders=array();//order ids
                      $args = array(
                          'numberposts'     =&gt; -1,
                          'meta_key'        =&gt; '_customer_user',
                          'meta_value'      =&gt; $current_user-&gt;ID,
                          'post_type'       =&gt; 'shop_order',
                          'post_status'     =&gt; 'publish',
                          'tax_query'=&gt;array(
                                  array(
                                      'taxonomy'  =&gt;'shop_order_status',
                                      'field'     =&gt; 'slug',
                                      'terms'     =&gt;'on-hold'
                                      )
                          )  
                      );
                      $posts=get_posts($args);
                      //get the post ids as order ids
                      $orders=wp_list_pluck( $posts, 'ID' );
                      $order = $orders[0];
                      /* Order Id ends here */
                      if($data){
                          $user_points = $data-&gt;points;
                          $points_set  = $data2-&gt;woo_pts_set;
                          print_r($woocommerce-&gt;cart-&gt;applied_coupons);
                          echo $woocommerce-&gt;cart-&gt;discount_cart;
                          echo $woocommerce-&gt;cart-&gt;get_cart_total();
                          /* the line below adds the cart discount to the Cart */
                          $woocommerce-&gt;cart-&gt;discount_cart = $data2-&gt;woo_discount_set;
                      }else{
                          echo 'You dont have any woo points yet.!!';
                      }
                  }
              }
  </code></pre>
  
  <p>How can I update the cart total on Cart Discount added?</p>