Different search instances for different users

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Different search instances for different users

This topic contains 3 replies, has 2 voices, and was last updated by jens021 jens021 5 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #21711
    jens021
    jens021
    Participant

    Hi

    I have created two different search instances. I want one of them (B) to be used only if the page body contains the class “wholesale_customer”, that is a wholesale customer is logged in, otherwise the other instance (A) should be used. I have now put the search instance (A) in the page with a short code.

    Greetings Stefan Elmgren

    #21717
    jens021
    jens021
    Participant

    The only difference between the two search instances is that one instance (A) excludes one product category (product_cat)
    //Stefan

    • This reply was modified 5 years, 1 month ago by jens021 jens021.
    #21723
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Stefan,

    Actually, this might be doable simply, because of that body class. So I’m assuming that search instance ID=1 is the one for the non-wholesale, and ID=2 is for the wholesale customers. To solve this, place both search shortcodes into the same place, where you need them.

    Then, use this custom CSS code:

    .asp_m_2 {
         display: none !imporant;
    }
    
    .wholesale_customer .asp_m_1 {
        display: none !important;
    }
    
    .asp_m_2 {
         display: block !imporant;
    }

    If you have different search bars with different IDs, then just change the numbers in the code.

    This is also doable with a single search bar & a different custo mcode, if it is somehow possible to check programatically if the current customer is a wholesale customer, but I think this should work as well.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #21776
    jens021
    jens021
    Participant

    Thanks for your answer.

    I solved it through JavaScript in a similar way.
    ——-
    if (jQuery(‘body’).hasClass(‘wholesale_customer’) ){
    jQuery(‘.asp_m_1’).css(‘display’, ‘none’);
    jQuery(‘.asp_m_2’).css(‘display’, ‘block’);
    }
    ——–
    Greetings Stefan Elmgren

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.