Search result link change

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years, 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #8450
    frankdm
    frankdm
    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 Marcinko
    Ernest 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.

    Best,
    Ernest Marcinko

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


    #8474
    frankdm
    frankdm
    Participant
    You cannot access this content.
    #8477
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Okays, I think I have a solution for you.

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

    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;
    }

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

    Best,
    Ernest Marcinko

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


    #8478
    frankdm
    frankdm
    Participant

    Thanks worked perfectly!

    #8479
    Ernest Marcinko
    Ernest 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.

    Best,
    Ernest Marcinko

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


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

You must be logged in to reply to this topic.