Woocommerce:在订单页面上显示产品变化描述 [英] Woocommerce: Display Product Variation Description on order page

查看:89
本文介绍了Woocommerce:在订单页面上显示产品变化描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在订单详细信息页面和订单电子邮件中显示产品版本描述.按照此示例 Woocommerce:在购物车页面上显示产品变化说明它非常适合购物车和结帐.但是似乎我找不到在订购页面上调用它的正确方法.

I am trying to display the product variation description in the order detail page and in the order email. Following this example Woocommerce: Display Product Variation Description on Cart page it worked perfectly for the cart and also for the checkout. But it seems i can't find the right way of calling it for the order page.

$item = $cart_item['data'];
if(!empty($item) && $item->is_type( 'variation' ) ){
    echo '<dl><dd>' . $item->get_variation_description() }

不起作用,因为它需要购物车项目数据. 以及此处建议的get_post_meta WooCommerce在可变价格后显示可变描述也不起作用.

is not working, as it calls for the cart item data .. And the get_post_meta as suggested here WooCommerce displaying variable description after variable price is not working either.

$_variable_description = get_post_meta( $variation->id , '_variation_description', true );

我试图将其放置在 order-details-item.php class-wc-order-item-meta.php 中,当然 email-order-details.php

I tried to place it in either the order-details-item.php and the class-wc-order-item-meta.php, and of course the email-order-details.php

有什么建议吗?谢谢!

推荐答案

我终于找到了一个可行的解决方案

I finally found a solution that worked here now showing the variation description on the order page and the order email.

add_filter( 'woocommerce_order_item_name', 'display_product_title_as_link', 10, 2 );
function display_product_title_as_link( $item_name, $item ) {

    $_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );

    $link = get_permalink( $_product->id );

    $_var_description ='';

    if ( $item['variation_id'] ) {
        $_var_description = $_product->get_variation_description();
    }

    return '<a href="'. $link .'"  rel="nofollow">'. $item_name .'</a><br>'. $_var_description ;
}

它将变体说明放在标题的正下方,但这对我有用.

It puts the variations description right below the title, but that works for me.

这篇关于Woocommerce:在订单页面上显示产品变化描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆