Php 获取产品永久链接-我的帐户-最近的订单

Php 获取产品永久链接-我的帐户-最近的订单,php,woocommerce,Php,Woocommerce,我一直在尝试添加一个产品缩略图图像,链接到客户最近订单页面上的产品,我在woocommerce中的帐户。 多亏了Anand,我成功地将图像缩略图放在适当的位置,从这里的这个问题: , 但现在我正在努力使这个拇指成为链接到实际产品的永久链接 所以我知道这是获取图像缩略图的代码: <?php // Get a list of all items that belong to the order $products = $order->get_items();

我一直在尝试添加一个产品缩略图图像,链接到客户最近订单页面上的产品,我在woocommerce中的帐户。 多亏了Anand,我成功地将图像缩略图放在适当的位置,从这里的这个问题: , 但现在我正在努力使这个拇指成为链接到实际产品的永久链接

所以我知道这是获取图像缩略图的代码:

<?php 
    // Get a list of all items that belong to the order
    $products = $order->get_items();

    // Loop through the items and get the product image
    foreach( $products as $product ) {                  

        $product_obj = new WC_Product( $product["product_id"] );

        echo $product_obj->get_image();

    }
?>

我一直在尝试将缩略图变成永久链接,如下所示:

<?php 
   // Get a list of all items that belong to the order
   $products = $order->get_items();

   // Loop through the items and get the product image
   foreach( $products as $product ) {                  

   $product_obj = new WC_Product( $product["product_id"] );

   echo '<a href="'.get_permalink($product_id).'"><?php echo $product_obj->get_image();?></a>';

   }
 ?>
echo '<a href="'.get_permalink($product_id).'">'echo $product_obj->get_image()'</a>';

或者像这样:

<?php 
   // Get a list of all items that belong to the order
   $products = $order->get_items();

   // Loop through the items and get the product image
   foreach( $products as $product ) {                  

   $product_obj = new WC_Product( $product["product_id"] );

   echo '<a href="'.get_permalink($product_id).'"><?php echo $product_obj->get_image();?></a>';

   }
 ?>
echo '<a href="'.get_permalink($product_id).'">'echo $product_obj->get_image()'</a>';
echo';
或者这个:

<a href="<?php echo $url = get_permalink( $product_id ); ?>">
    <?php 
           // Get a list of all items that belong to the order
           $products = $order->get_items();

           // Loop through the items and get the product image
           foreach( $products as $product ) {                  

           $product_obj = new WC_Product( $product["product_id"] );

           echo $product_obj->get_image();

        }
     ?>

非常简单,Product类有一个
get\u permalink
方法,您可以这样使用:

$product_obj = new WC_Product( $product["product_id"] );

$link = $product_obj->get_permalink();

echo '<a href="'. $link .'">' . $product_obj->get_image() . '</a>';
您在下面的代码中使用了
$product\u id
,因为在代码不起作用的地方没有定义它。你非常接近:)

echo';

效果很好!再一次,非常感谢,你帮了我很大的忙!乐意帮忙:)快乐编码