Okay
  Public Ticket #1732869
Open product page in new window
Closed

Comments

  •  8
    pechenintimur started the conversation

    Hi there!

    At the moment, all the products from the directory opened in the same window. Is there a solution to open internal products from the catalog in a new window?

    It would be great to have this feature implemented through a plugin or code. Do you already have the practice of solving this issue?

    _

    Timur

  •  1,560
    Laborator replied

    Hi Timur,

    Are you talking about the products in shop so when you click them, they open on a new window or tab.

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group

  •  8
    pechenintimur replied

    Dear Art.

    Unfortunately, we didn't understand each other. At the moment, all products from catalogue open on the same window. I would like to be able to open products from the catalog on the new window by default.

    I have tried to add this code to file functions.php but unfortunately it doesn't work.

    Code:

    /* Open Products in New Tab Woocommerce-DevelopingSense */

    remove_action( 'woocommerce_before_shop_loop_item','woocommerce_template_loop_product_link_open', 10 );
    // add a hook to my custom function
    add_action ( 'woocommerce_before_shop_loop_item', 'ami_function_open_new_tab', 10 );
    function ami_function_open_new_tab() {
    echo '<a target="_blank" href="' . get_the_permalink() . '" class="woocommerce-LoopProduct-link">';
    }


    _

    Timur

  •  1,560
    Laborator replied

    Hi Timur,

    To do this you will need to replace laborator_woocommerce.php which is under /inc (within the theme folder), after you've done that go to the functions.php file of your child theme and add this code at the end of it:

    function aurum_product_link_target_blank( $target ) {
            return '_blank';
    }
    add_filter( 'aurum_product_link_target', 'aurum_product_link_target_blank' );
    

    If you don't know how to do it then please share your site credentials here, because we need to login to your site and see this issue live. Your information is safe (private) in this thread.

    To include your credentials click Insert Credentials button in editor toolbar. (See how)

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group

  •   pechenintimur replied privately
  •   pechenintimur replied privately
  • [deleted] replied

    Hi Timur,

    I have added the following code in functions.php:

    // Open product in new tab
    function woocommerce_template_loop_product_link_open() {
        global $product;
        $link = apply_filters( 'woocommerce_loop_product_link', get_the_permalink(), $product );
        echo '<a href="' . esc_url( $link ) . '" class="woocommerce-LoopProduct-link woocommerce-loop-product__link" target="_blank">';
    }
    function aurum_product_link_target_blank( $target ) {
        return '_blank';
    }
    add_filter( 'aurum_product_link_target', 'aurum_product_link_target_blank' );
    
    and now products are open in new tab:

    https://d.pr/v/rpEjtT