Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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;
    }
    Thread Starter mseif

    (@mseif)

    Thank you very much Sumit!!
    It’s working great now!

Viewing 2 replies - 1 through 2 (of 2 total)