Support » Plugin: Advanced Woo Search » Can we show attributes in the search form?

  • Resolved techiebraj

    (@techiebraj)


    Hello team,

    I have some products with model and brand in it, I want to show models and brand in the search form as like it shows for SKU, is it possible?

    I am talking about this: https://prnt.sc/s7bjei

    Thank you so much!

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Also, I have to edit the SKU: to OEM: in the search bar here: https://prnt.sc/s7fhbd

    I have Loco Translate installed. I tried to edit SKU: word to OEM in WooCommerce as well as Advance Woo Search Plugin but my change is not reflecting here. Where to edit this SKU text to OEM.

    I cleared the cache of my cache plugin as well as AWS and Reindexed the table but the text is still not changing.

    AWS: https://prnt.sc/s7fk5v
    WooCommerce: https://prnt.sc/s7fksk

    Not reflecting: https://prnt.sc/s7fljr

    Thanks!

    Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    About SKU string translation – please tell me plugin version number that you are currently using.

    About models and brand display – yes, it is possible. You will need to use little code snippet for this.
    But first please tell me how you add this models and brand to the product – it is product attributes or maybe some custom fields?

    Regards

    Hello and thanks for your reply:)

    For string translation – I am using all the latest versions of all the plugin installed on my site including Advance Woo Search, WooCommerce & Loco Translator.

    About models and brand display – Its not a custom field, it is just default attribute by WooCommerce.

    Regards,
    Braj

    • This reply was modified 3 months, 1 week ago by techiebraj.
    • This reply was modified 3 months, 1 week ago by techiebraj.
    Plugin Author ILLID

    (@mihail-barinov)

    Please use following code snippet

    add_filter( 'aws_excerpt_search_result', 'aws_excerpt_search_result', 10, 3 );
    function aws_excerpt_search_result( $excerpt, $post_id, $product ) {
        $attribute = $product->get_attribute('pa_brand');
        if ( $attribute ) {
            $excerpt = $excerpt . '<br>' . $attribute;
        }
        return $excerpt;
    }

    change pa_brand with the proper slug of your product attribute than you want to display

    You need to add this code somewhere outside plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.

    Also after adding this code you will need to go to the plugin settings page and click ‘Clear cache’ button.

    Regards

    Thank you so much for the code snippet 🙂

    I have two attributes in all of my product i.e., Brand & Model. The slug of both are as follows:-

    Brand: brand
    Model: model

    I have added your code by replacing the “pa_brand” to “brand“.

    My code: https://prnt.sc/s8v388
    This is how it looks after adding the code: https://prnt.sc/s8v3qu

    However, I need some improvement in this snippet, such as:-

    Right now it only shows parent attribute, I want it to show also the child attribute. My parent attribute is “BRAND” & the child is “MODEL“.

    I want it to show below SKU without line break exactly how SKU shows: https://prnt.sc/s8v5y2

    Like below:-

    SKU:
    Brand:
    Model:

    Note: The value of the brand and modelshould be in BOLD how SKU value shows.

    Regards

    Plugin Author ILLID

    (@mihail-barinov)

    If you want to made it bold and remove line bread please replace

    $excerpt = $excerpt . '<br>' . $attribute;

    with

    $excerpt = $excerpt . '<b>' . $attribute . '</b>';

    About parent attributes – can you please give me the screenshot of you admin page with attributes page? I need to see the structure of your attributes?

    Regards

    Thanks 🙂

    Below is the screenshot of my attributes:-

    1- https://prnt.sc/s93zeg
    2- https://prnt.sc/s93zrh
    3- https://prnt.sc/s94001
    4- https://prnt.sc/s94125
    5- https://prnt.sc/s9417s

    The website is in Spanish, so we call Brand to MARCA & Model to MODELO.

    Thank you so much for all your help 🙂

    Plugin Author ILLID

    (@mihail-barinov)

    Well as know it is not possible to set product attributes hierarchy.
    What I see on your screenshots is than brand and model are just two separated attributes.
    So just use code

    add_filter( 'aws_excerpt_search_result', 'aws_excerpt_search_result', 10, 3 );
    function aws_excerpt_search_result( $excerpt, $post_id, $product ) {
        $brand = $product->get_attribute('brand');
        $model = $product->get_attribute('model');
        if ( $brand ) {
            $excerpt = $excerpt . '<b>' . $brand . '</b>';
        }
        if ( $model ) {
            $excerpt = $excerpt . '<br><b>' . $model . '</b>';
        }
        return $excerpt;
    }

    to show them both.

    Regards

    techiebraj

    (@techiebraj)

    Thank you so much for the reply 🙂

    This code gives this output: https://prnt.sc/s9rdu1

    I also want it to show MARCA: & MODEO: before the attribute like it shows for SKU e.g., SKU: 112111

    I want it to show like below:-

    SKU: 1121111
    MARCA: HYUNDAI
    MODELO: TUCSON

    Also, I have to translate SKUto OEM as I mentioned before but I am not able to do it with Loco Translate, can you tell me how to translate from SKU to OEM? e.g., OEM: 112111

    Thank you so much!

    Plugin Author ILLID

    (@mihail-barinov)

    Wel in this case use code

    add_filter( 'aws_excerpt_search_result', 'aws_excerpt_search_result', 10, 3 );
    function aws_excerpt_search_result( $excerpt, $post_id, $product ) {
        $brand = $product->get_attribute('brand');
        $model = $product->get_attribute('model');
        if ( $brand ) {
            $excerpt = $excerpt . 'MARCA: <b>' . $brand . '</b>';
        }
        if ( $model ) {
            $excerpt = $excerpt . '<br>MODELO: <b>' . $model . '</b>';
        }
        return $excerpt;
    }

    About SKU translation – please use code

    add_filter( 'gettext', 'my_gettext', 10, 3 );
    function my_gettext( $translation, $text, $domain ) {
        if ( $domain === 'advanced-woo-search' && $text === 'SKU' ) {
            $translation = 'OEM';
        }
        return $translation;
    }
    techiebraj

    (@techiebraj)

    Hello!

    Thank you very much, both codes worked perfectly for me 🙂

    I am really amazed by your awesome support even on this free version of this plugin, I have decided to go for the pro version. Do you have any promo code for me so that I will get some extra discount while purchasing?

    Thanks again:)

    • This reply was modified 3 months ago by techiebraj.
    • This reply was modified 3 months ago by techiebraj.
    Plugin Author ILLID

    (@mihail-barinov)

    Sorry, questions about paid plugins versions are not allowed on this forum.
    I can email me to wpunitnet@gmail.com

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.