【发布时间】:2015-12-10 14:08:31
【问题描述】:
我一直在尝试在 woocommerce 中的“我的帐户”客户最近的订单页面上添加链接到产品的产品缩略图。 感谢Anand,我已经设法从这个问题中获得了图像缩略图: Add Product Thumbnail to My Account - Recent Orders - Woocommerce, 但现在我正在努力让这个拇指成为链接到实际产品的永久链接。
所以我知道这是获取图像缩略图的代码:
<?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>';
或者这个:
<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();
}
?>
但似乎无法靠近..?
【问题讨论】:
标签: php woocommerce