Support » Plugin: Advanced Woo Search » Custom url on product click

  • Resolved ninievy

    (@ninievy)


    Hello,

    I would like to know if it is possible to use a custom URL with the product ID (or name of the product) when clicking on one of the product Of the search result ?

    Usually when clicking on a product displayed by the search result it leads right to the product page. And what I want to do is to use the search Box to find a product and when clicking on it, I want to use the product ID or name to pass it into a custom URL (this URL will be displaying a contact form to do a quote request with the product selected).

    Hope I am clear enough.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Yes, it is possible. You can use aws_search_results_products filter to achieve this.
    Use code snippet like

    add_filter( 'aws_search_results_products', 'my_aws_search_results_products', 10 );
    function my_aws_search_results_products( $products_array ) {
        if ( ! empty( $products_array ) ) {
            foreach( $products_array as $key => $product ) {
                $products_array[$key]['link'] = 'https://custom-link.com?id=' . $product['id'];
            }
        }
        return $products_array;
    }

    It’s will generate custom link like https://custom-link.com?id=[PRODUCT_ID].
    Change this url to whatever you need.

    Regards

    • This reply was modified 2 years, 3 months ago by ILLID.
    Thread Starter ninievy

    (@ninievy)

    Sorry I thought I left a reply but didn’t. Thanks for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom url on product click’ is closed to new replies.