php - 在 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;
}
}
解决方案
推荐阅读
- rmysql - 我的本地主机中有学生数据库,但它仍然显示这个
- kubernetes - 如何为 Kubernetes 集群中运行的所有不同应用程序设置单独的 DNS 端点???(AWS/GCP/天蓝色)
- android - 如何在 MoPub 中集成 Chartboost 中介?
- nginx - GRPC 流在写入之前关闭(通过 nginx 的 grpc_pass)
- reactjs - 如何描述何时在反应中使用术语“方法”与“功能”?
- python - 无法获取超链接href美汤
- flutter - 在 Flutter 的 SliverAppBar 中添加 AppBar
- git - 如果通过 --depth=1 克隆存储库,如何获取存储库的 git 历史记录
- c++ - 程序中的内存泄漏以在 C++ 中实现链表
- python - 如何在一定区间内绘制相同宽度不同高度的bin的直方图?