Topic Resolution: Resolved
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #3236
    AvatarBakana Media
    Support Expired

    Hello,

    I wanted to know if it was possible to change the link of the “add to cart” button but only for specific items?

    screenshot

    #3238

    Please go to edit product -> Product data -> External/Affiliate product -> Add Product URL: https://prnt.sc/1eeam4d

    #3239
    AvatarBakana Media
    Support Expired

    Thank you

    #3241

    Ok you.

    #3320
    AvatarBakana Media
    Support Expired

    Hello,

    I thought that the problem was solved but finally not.

    When I click on the button with the cart icon it works, but when I click on the title of the article it redirects me to the article page

    Screenshot

    Blue : Works – Red : Does not work

    #3321

    Please add this php code to file functions.php ( child-theme):

    remove_action('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open');
    add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_link_open', 15);
    add_action('woocommerce_before_shop_loop_item', 'woocommerce_add_aff_link_open', 10);
    add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_add_aff_link_close', 10);
    
    function woocommerce_add_aff_link_open(){
        $product = wc_get_product(get_the_ID());
    
        if( $product->is_type( 'external' ) ) {
            echo '<a target="_blank" href="' . $product->get_product_url() . '" class="">';
        }
    }
    
    function woocommerce_add_aff_link_close(){
        $product = wc_get_product(get_the_ID());
    
        if( $product->is_type( 'external' ) ) {
            echo '</a>';
        }
    }
    #3324
    AvatarBakana Media
    Support Expired
    This reply has been marked as private.
    #3330

    HI,

    Please don’t edit your site, I’m checking your site.

    #3331

    I resolved this issue, please recheck.

    #3332
    AvatarBakana Media
    Support Expired

    Perfect, thank you very much for your help

    #3333

    OK, you are welcome!

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.