在Woocommerce客户订单页面

时间:2020-10-18 01:28:44

标签: php html wordpress woocommerce storefront

我正在尝试在Woocommerce店面主题的“我的帐户”部分的“订单”页面中添加另一列。在此列中,我想按顺序显示产品的缩略图。我已经尝试过Show Product Image In orders Page WoocommerceAdd Product Thumbnail to My Account中的建议代码。但是,均未显示产品图像。我已经设法使用此代码将产品的缩略图显示在订单的“查看”部分中,但是不确定如何将这些元素合并到“订单”页面上的新列中

// Display the product thumbnail in order view pages
add_filter( 'woocommerce_order_item_name', 'display_product_image_in_order_item', 20, 3 );
function display_product_image_in_order_item( $item_name, $item, $is_visible ) {
    // Targeting view order pages only
    if( is_wc_endpoint_url( 'view-order' ) ) {
        $product   = $item->get_product(); // Get the WC_Product object (from order item)
        $thumbnail = $product->get_image(array( 36, 36)); // Get the product thumbnail (from product object)
        if( $product->get_image_id() > 0 )
            $item_name = '<div class="item-thumbnail">' . $thumbnail . '</div>' . $item_name;
    }
    return $item_name;
}

我还希望每列中的图像充当指向产品页面的链接,就像产品标题充当“订单详细信息”页面上的链接一样。结果应该看起来像like this

任何建议将不胜感激!

0 个答案:

没有答案