title: How to create custom discount for the cart in woocommerce
body: <p>I'm creating a Plugin in WooCommerce and have a small issue with adding custom discounts to the CART / CHECKOUT page.</p>
  
  <p>How can I apply custom discount to the cart without creating coupons?
  Say I want to give some discount of 5 dollars on the cart page. How can I do that? </p>
  
  <p>Below is my code from the plugin file where I have used a coupon to apply discount, but I want to add another custom discount without the use of coupon.</p>
  
  <p>Action Hook in the plugin file :</p>
  
  <pre><code>add_action('woocommerce_calculate_totals',array(&amp;$this,'cart_order_total_action'));
  </code></pre>
  
  <p>and its function in the plugin file is :</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);
          $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;
              $coupon_code = 'wooreward_discount';
              if($user_points&gt;=$points_set){
                  // this following Code is optional and can be removed......as there is no need of if statement here
                  if ( $woocommerce-&gt;cart-&gt;has_discount( $coupon_code ) ) {
                      /*$woocommerce-&gt;add_error( __('Coupon Code Already Applied.!!','woocommerce'));*/
                      return false;
                  }else{
                      $woocommerce-&gt;cart-&gt;add_discount(sanitize_text_field($coupon_code));
                      $woocommerce-&gt;add_message( __('Taxco925 Reward Discount Applied.!!','woocommerce'));
                  }
              }else{
                  $woocommerce-&gt;add_error( __('Not Enough Taxco925 Points.!!','woocommerce'));
              }
          }else{
              $woocommerce-&gt;add_error( __('You have have not earned any Taxco925 Points yet.!!','woocommerce'));
          }
      }
  }
  </code></pre>
  
  <p>As you can see this line <code>$woocommerce-&gt;cart-&gt;add_discount(sanitize_text_field($coupon_code));</code>
  adds my discount to the cart. But it uses coupon in the background to do so . Is there any way I can add a custom discount without the use of coupon.</p>