Home > OS >  WooCommerce hide coupon field , but not for logged in users
WooCommerce hide coupon field , but not for logged in users

Time:02-01

I try to get my coupon field hidden but I would like to keep it on for logged-in users. On this code, it does not work. What can be my solution?

function hide_coupon_field_on_cart( $enabled ) {
    if( !is_user_logged_in() )
          return $disabled;
    if ( is_cart() ) {
        $enabled = false;
    }
    return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' ); 

CodePudding user response:

function hide_coupon_field_on_cart( $enabled ) {
    if( !is_user_logged_in() ){
          return false;
    }
    return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' ); 
  • Related