adding a coupon programatically in woo commerce

I'm trying to program a coupon into woocommerce using the following code but i don't think I have the code right heres a break down of what I'm trying to do
i need a system that will allow the coupon to discount down products to 20 pounds and 40 60 etc when a customer orders 5 10 and 15 e liquids

add_action( 'woocommerce_before_cart', 'apply_matched_coupons' );

function apply_matched_coupons() {
    global $woocommerce;

    $get1 = '5for20'; // your coupon code here
    $get2 = '10for40'; // your coupon code here
    $get3 = '15for60'; // your coupon code here
    $get4 = '20for80'; // your coupon code here

    $autocoupon = array(13);
    if(in_array($values['product_id'],$autocoupon)){ 

    if ( $woocommerce->cart->cart_contents_count >= 5 && $woocommerce->cart->cart_contents_count < 10 ) {
        $woocommerce->cart->add_discount( $get1 );
        $woocommerce->show_messages();
    } elseif ( $woocommerce->cart->cart_contents_count >= 10 && $woocommerce->cart->cart_contents_count < 15 ) {
        $woocommerce->cart->add_discount( $get2 );
        $woocommerce->show_messages();
    } elseif ( $woocommerce->cart->cart_contents_count >= 15 && $woocommerce->cart->cart_contents_count < 20 ) {
        $woocommerce->cart->add_discount( $get3 );
        $woocommerce->show_messages();
    } elseif ( $woocommerce->cart->cart_contents_count >= 20 && $woocommerce->cart->cart_contents_count < 21 ) {
        $woocommerce->cart->add_discount( $get4 );
        $woocommerce->show_messages();
    } 

}