• Resolved Craig

    (@divithemeexamples)


    Hey

    im updating outdated template files on my site and the last one is;

    Divi-child/woocommerce/single-product/add-to-cart/external.php version 2.1.0 is out of date. The core version is 3.4.0,

    i am using this to open the links in a new tab by adding the target=”_blank” here in my current outdated file

    <p class=”cart”>
    ” rel=”nofollow” class=”single_add_to_cart_button button alt” target=”_blank”><?php echo esc_html( $button_text ); ?>
    </p>

    BUT, when i update with the latest version of this file and try and add the target+”_blank” it is not working. any ideas why?

    this is the full code for the updated file;

    <?php
    /**
    * External product add to cart
    *
    * This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/external.php.
    *
    * HOWEVER, on occasion WooCommerce will need to update template files and you
    * (the theme developer) will need to copy the new files to your theme to
    * maintain compatibility. We try to do this as little as possible, but it does
    * happen. When this occurs the version of the template file will be bumped and
    * the readme will list any important changes.
    *
    * @see https://docs.woocommerce.com/document/template-structure/
    * @package WooCommerce/Templates
    * @version 3.4.0
    */

    defined( ‘ABSPATH’ ) || exit;

    do_action( ‘woocommerce_before_add_to_cart_form’ ); ?>

    <form class=”cart” action=”<?php echo esc_url( $product_url ); ?>” method=”get”>
    <?php do_action( ‘woocommerce_before_add_to_cart_button’ ); ?>

    <button type=”submit” class=”single_add_to_cart_button button alt” target=”_blank”><?php echo esc_html( $button_text ); ?></button>

    <?php wc_query_string_form_fields( $product_url ); ?>

    <?php do_action( ‘woocommerce_after_add_to_cart_button’ ); ?>
    </form>

    <?php do_action( ‘woocommerce_after_add_to_cart_form’ ); ?>

    thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support John Coy a11n

    (@johndcoy)

    Automattic Happiness Engineer

    Hi @divithemeexamples,

    Add the target class to the form rather than the button. It should look something like this:

    <form class="cart" action="<?php echo esc_url( $product_url ); ?>" method="get" target="blank">

    Hope that helps,

    Thread Starter Craig

    (@divithemeexamples)

    perfect. works. many thanks ??

    Thread Starter Craig

    (@divithemeexamples)

    one thing i noticed is that you can no longer right click and copy link in the browser… not a major issue but seems strange. is that how it is supposed to work?

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘open external products in new tab’ is closed to new replies.