• Resolved metikar

    (@metikar)


    Hi
    I am trying to hide the upload field by using woocommerce_checkout_fields filter then unset ting the field unset($fields[‘alg_checkout_files_upload’] according to a certain conditions

    ex

    add_filter( 'woocommerce_checkout_fields', 'hide_prefilled_fields',99999 );
    function hide_prefilled_fields( $fields ) {
    $user_id = get_current_user_id();
    $orders = wc_get_orders( array(
    'customer' => $user_id,
    'status' => array( 'wc-completed' ),
    'date_created' => '>=' . strtotime('-2 months')
    ) );
    if ( ! empty( $orders ) ) {
    foreach ( $orders as $order ) {
    $user_registered_name = $order->get_meta('_user_registered_name');
    if ( ! empty( $user_registered_name ) ) {
    unset($fields['alg_checkout_files_upload']);
    }
    }
    }
    return $fields;
    }
    
    
    
    


    Is that possible to hide the upload field using fields filter ?

    • This topic was modified 1 year, 4 months ago by metikar.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide upload field using filter’ is closed to new replies.