• Resolved kasimrixa

    (@kasimrixa)


    Hello team,

    In the https://www.example-domain.com/wishlist where the products are depicted in a table I’m trying to make the button (add to cart) to open in a new tab.

    I have external products, I’m trying to change the code without success

    <button  class="button alt" name="tinvwl-add-to-cart"
    value="<?php echo esc_attr( $wl_product['ID'] );?>"
    title="<?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_cart', $wishlist_table_row['text_add_to_cart'], $wl_product, $product ) ); ?>">
    <i class="ftinvwl ftinvwl-shopping-cart"></i><span
    class="tinvwl-txt"><?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_cart', $wishlist_table_row['text_add_to_cart'], $wl_product, $product ) ); ?></span>
    </button> 

    Can you help to make the products on the wishlist page to open in a new tab?

    Thank you

Viewing 1 replies (of 1 total)
  • Plugin Support Stan

    (@stantinv)

    Hello @kasimrixa,

    You can use the next snippet to make products open in a new window:

    /**
     * External products buy button open in a new window.
     *
     * @param boolean $allow Settings flag.
     * @param array $wlproduct Wishlist Product.
     * @param WC_Product $product Product.
     *
     * @return boolean
     */
    function external_products_buy_link( $allow, $wlproduct, $product ) {
    
    	// If a product type is external.
    	if ( is_object( $product ) && 'external' === $product->get_type() ) {
    		// Create a button using product Url and button text.
    		echo '<a href="' . $product->add_to_cart_url() . '" target="_blank" class="button alt">' . $product->single_add_to_cart_text() . '</a>';
    
    		// Disable default add to cart button.
    		return false;
    	}
    
    	return $allow;
    }
    
    add_filter( 'tinvwl_wishlist_item_action_add_to_cart', 'external_products_buy_link', 100, 3 );

    Put the code into a functions.php file of your child-theme.

    Regards,
    Stan

Viewing 1 replies (of 1 total)
  • The topic ‘Wishlist product open in a new tab’ is closed to new replies.