Include product custom field value for search result

This topic has 4 replies, 2 voices, and was last updated 5 years, 5 months ago ago by Rose Tyler

  • Avatar: r1nk
    r1nk
    Participant
    October 31, 2018 at 16:35

    Hello, currently the search function will show result based on the product title/product category/etc.

    In functions.php, I manually create a custom field. This is the codes :-

    /** Add Sub-Title option in Woocommerce */
    
    add_action( 'woocommerce_product_options_general_product_data', 'my_custom_field' );
    
    function my_custom_field() {
    
    woocommerce_wp_text_input( 
        array( 
            'id'          => '_subtitle', 
            'label'       => __( 'Reference', 'woocommerce' ), 
            'placeholder' => 'Reference code',
            'description' => __( 'Enter the reference code', 'woocommerce' ) 
        )
    );
    
    }
    
    add_action( 'woocommerce_process_product_meta', 'my_custom_field_save' );
    
    function my_custom_field_save( $post_id ){  
    
        $subtitle = $_POST['_subtitle'];
        if( !empty( $subtitle ) )
            update_post_meta( $post_id, '_subtitle', esc_attr( $subtitle ) );
    
    }

    Now, can I include this meta field value for the search result too? Where I should edit the code?

    3 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    November 1, 2018 at 09:03

    Hello,

    I would recommend you to contact WooCommerce support.

    Regards

    Avatar: r1nk
    r1nk
    Participant
    November 4, 2018 at 05:52

    Hello,

    OK. Anyway may I know if you guys wrote any custom code that related to indexing?

    If yes, may I know where the code sits? Since I tried using additional search result plugin, and the indexing took so long and one of the reason might be because of the custom code related to indexing.

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    November 5, 2018 at 10:32

    Hello,

    In theme-functions.php you may find two functions which you may change via your child-theme/functions.php
    et_get_search_result
    et_search_get_result

    Regards

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.