• Resolved mseif

    (@mseif)


    Hi!
    In the search results, if I click any of ‘Add to cart’ buttons,
    it redirects to home page. I need it stays there in the search results page
    and not redirect anywhere.
    Is there any way to achieve this?. I can modify the code or add a snippet if necesary.
    Thank you!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sumit Singh

    (@5um17)

    Hi,

    This seems to be a bug. Thanks for reporting it.

    As a workaround, please enable Ajax to add products to cart.
    Go to WooCommerce > Settings > Products and enable “Enable AJAX add to cart buttons on archives”
    I will fix this in future release.

    Thanks

    Thread Starter mseif

    (@mseif)

    Hi Sumit!
    Thank you very much for your quick respose.
    Great plugin by the way! 😉
    I’d forgotten I added some code to show qty input beside ‘Add to cart’ buttons.
    So I changed it a little bit to redirect to store after click inside search results. Its good enough for now.
    Here’s the code in case is usefull for someone:

    add_filter( 'woocommerce_loop_add_to_cart_link', 'qty_inputs_for_add_to_cart' );
    function qty_inputs_for_add_to_cart( $html, $product ) {
        if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
            global $wp;
            if(strlen($wp->request) == 0){
                $html = '<form action="/tienda/' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
            }else{
                $html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
            }
            $html .= woocommerce_quantity_input( array(), $product, false );
            $html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
            $html .= '</form>';
        }
        return $html;
    }
    Plugin Author Sumit Singh

    (@5um17)

    Hi,

    I have added a fixed and released a new version. Please update to the latest version.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirect to home after ‘add to cart’’ is closed to new replies.