首页 > 解决方案 > 在 WooCommerce 管理订单项目上显示“产品描述”

问题描述

产品类型是可变的。但我不想显示变量描述。

即使产品类型是可变产品,我也想显示产品描述。

如果您看到上传的图像,您就可以理解。

我编辑了 7uc1f3r 的一小部分代码。

有人可以修复低于 7uc1f3r 的代码吗?

在此处输入图像描述

function action_woocommerce_before_order_itemmeta( $item_id, $item, $product ) {
    // Targeting line items type only
    if ( $item->get_type() !== 'line_item' ) return;
    
    // Variable 
    if ( $product->get_type() == 'variation' ) {
        // Get the variable product description
        $description = $product->get_description();     
    } else {
        // Get product desciption
        $description = $product->get_description();       
    }
    
    // Isset & NOT empty
    if ( isset ( $description ) && ! empty( $description ) ) {
        echo $description;
    }
}

标签: phpcssvariablesactionmeta-tags

解决方案


推荐阅读