• Resolved Jeroen

    (@jjw-1)


    How can we search for a value from the custom fields?

    We have ‘billing_leerlingnr’ as a custom field. We try to find this value in the WooCommerce order search, but is doesn’t show any results:

    add_filter( 'woocommerce_shop_order_search_fields', 'VF_search_custom_fields' );

    function VF_search_custom_fields( $search_fields ) {
    $search_fields[] = '_billing_leerlingnr';
    return $search_fields;
    }

    Is there a solution to be able to show the custom data after search in Woocommerce > Orders?

    add_filter( 'woocommerce_shop_order_search_results', 'VF_search_leerlingnr_field', 10, 3 );

    function VF_search_leerlingnr_field( $order_ids, $term, $search_fields ) {
    global $wpdb;

    $query = $wpdb->prepare(
    "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_th_wccl_customized_fields' AND meta_value LIKE %s",
    '%' . $wpdb->esc_like( $term ) . '%'
    );

    $results = $wpdb->get_col( $query );

    if ( $results ) {
    $order_ids = array_unique( array_merge( $order_ids, $results ) );
    }

    return $order_ids;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Dina S.

    (@themehighsupport)

    Hi,

    Unfortunately, your requirement cannot be achieved using the lite version of our plugin.

    Thank you!

    Thread Starter Jeroen

    (@jjw-1)

    Thank you? haha, ok, no thanks for that ??

    Is it achievable with the paid version of the plugin? And can we use the snippet above in that case?

    Plugin Support Dina S.

    (@themehighsupport)

    As per the WordPress forum policy, we can’t answer premium related questions on this forum. Could you please raise a ticket through our website? We hope our technical team will be able to help you.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Search for custom field’ is closed to new replies.