Woocommerce: how to form a dynamic link for iframe

Viewed 101

I use Woocommerce for my store.Instead of product photos, I should have an iframe that pulls up the necessary photos from another application. To do this, I need to create a dynamic link that will take the product’s ID.Link like that

var Link = 'http://sameurl/'  + product_Id;

I do not know how to do it in Woocommerce. There is a function that receives the product id and displays an iframe. How do I form a link for him correctly

function product_image(){
    $product = wc_get_product();
    $product_id = $product->get_id();
    $threedLink = 'http://sameurl/' + $product_id ;
    ?>
    <div class="wrap">
    <iframe src="<?php echo $threedLink; ?>" width="99%" height="300px"></iframe> 
    </div>
    <?php

}

This link does not work.

1 Answers

I found a solution who can come in handy

function product_image(){
    $product = wc_get_product();
    $product_id = $product->get_id();
    $threedLink = 'http://sameurl/' .$product_id ;
    $content .= '<iframe src='.$threedLink.'  width="99%" height="300px"></iframe>';
    return $content;

}
Related