1

How can I open this in new tab via php?

enter image description here

I tried to open this cart and wish list page in a new tab but its showing a blank page,

add_filter( 'woocommerce_loop_add_to_cart_link', 'businessbloomer_add_target_blank', 10, 2 );
 
function businessbloomer_add_target_blank( $product, $args ){
 
$link = sprintf( '<a href="%s" target="_blank" data-quantity="%s" class="%s" %s>%s</a>',
        esc_url( $product->add_to_cart_url() ),
        esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
        esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
        isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
        esc_html( $product->add_to_cart_text() )
);
 
return $link;
 
}

this is the example link... http://hero.woxear.com/

Dave
  • 5,108
  • 16
  • 30
  • 40
Dexter Fox
  • 19
  • 2
  • I think you should try to reverse the quotes – executable Dec 14 '18 at 14:57
  • 1
    May be try target=“_new” instead of blank. – estinamir Dec 14 '18 at 15:09
  • 1
    Those links with the `data-quantity` attribute are the (+) links on the product cards, to add a product to the cart. Your screenshot indicates that you want to manipulate the shopping cart and wishlist icon in the header, so this is the wrong hook to begin with (clue kinda in the name here.) And if you actually inspect those icons, you see that the links around them are of the form ` – misorude Dec 14 '18 at 15:14
  • "its showing a blank page" -> check your error logs; see https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12772851#12772851 – IMSoP Dec 14 '18 at 15:31

0 Answers0