Okay
  Public Ticket #1811868
Direct link to affiliation website
Closed

Comments

  • jean started the conversation

    Hello again! I would like you to click on the product image to send me directly to the purchase url without going through the product description page.
    I have tried with this code but it does not work.

    remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
    add_action( 'woocommerce_before_shop_loop_item', 'tsa_woocommerce_link_nofollow', 10 );
    function tsa_woocommerce_link_nofollow() {
    global $product;
    if ( $product->is_type('external') ) {
    echo '<a target="_blank" rel="nofollow" class="woocommerce-LoopProduct-link" href="' . $product->get_product_url() . '">';
        }else{
        echo '<a href="' . get_the_permalink() . '" class="woocommerce-LoopProduct-link">';
        }
    }

    Would you know how to help me?


  •  77
    ThemeMove replied

    Hi,

    Could you please send me 

    • The WordPress admin information (login URL, username & password)
    • The FTP login information (server address, username & password)

    So, I can give a thorough check and find a solution for you.

    Do not forget to set your answer as private

    Best Regards,

    Thememove Team.

  •   jean replied privately
  •  77
    ThemeMove replied

    Hi,

    In the setting product data, please choose External/ Affiliate product and enter the external URL to the product, like here: http://prntscr.com/lu9yss

    Then, add custom code below:

    remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
    add_action( 'woocommerce_before_shop_loop_item', 'tsa_woocommerce_link_nofollow', 10 );
    function tsa_woocommerce_link_nofollow() {
        global $product;
        if ( $product->is_type( 'external' ) ) {
            echo '<a target="_blank" rel="nofollow" class="woocommerce-LoopProduct-link link-aff" href="' . $product->get_product_url() . '">';
        } else {
            echo '</a><a href="' . get_the_permalink() . '" class="woocommerce-LoopProduct-link">';
        }
    }
    

    And finish, add custom CSS (in your child theme or Theme Option >> Custom Code >> Custom CSS):

    .product.product-type-external > a {
        display: none;
    }
    .product.product-type-external .link-aff {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
    }
    

    I tested it and work fine. Hope will help you!

    Best Regards,

    Thememove Team.


    Best Regards,

    Thememove Team.