This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Search result link change

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #8450
    frankdmfrankdm
    Participant

    Dear Support

    I have installed and configured my search. I am using Woo-commerce. I would like to change it so that every result when clicked adds that product to the cart (so it does not go to the product page no more).

    This is my first time using premium plugin support, so hopefully this works out!

    Thank you!
    Frank

    #8470
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    Can you please provide an URL to your website, where I can check your shop and the add to cart urls?
    I need to see how it works on your installation in order to suggest a change or modification.

    #8474
    frankdmfrankdm
    Participant

    You cannot access this content.

    #8477
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Okays, I think I have a solution for you.

    Put this code to the functions.php file in your active theme directory:

    [php]add_filter( ‘asp_results’, ‘asp_links_to_addtocart’, 1, 1 );

    function asp_links_to_addtocart( $results ) {
    foreach ($results as $k=>$r) {
    // Modify the URL
    $results[$k]->link = "/?add-to-cart=".$r->id."&quantity=1";
    }
    return $results;
    }[/php]

    That will change the results URLs to the add to cart WooCommerce URLs.

    #8478
    frankdmfrankdm
    Participant

    Thanks worked perfectly!

    #8479
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Great, I’m glad I could help you!

    If you like the plugin, feel free to rate it on your codecanyon downloads page, it’s greatly appreciated.

    I will close this thread and mark it as resolved now. If you have any other issues or questions, feel free to open another one.

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