这些帖子与Add a custom total line to WooCommerce admin order totals有关

你好

我正在try 隐藏小计,但在css中找不到类,如下所示:

.cart-subtotal  { display: none; }
.order-total { display: none;    }
.order_shipping_line_items {display: none;}

这不管用.

现在我试图用这些代码取消设置,但它也不起作用:

add_filter( 'woocommerce_get_order_item_totals', 'reordering_order_item_totals', 10, 3 );
function reordering_order_item_totals( $total_rows, $order, $tax_display ){
    $shipping = $total_rows['line_subtotal'];
    $order_total = $total_rows['order_total'];

    unset($total_rows['line_subtotal']);
    unset($total_rows['order_total']);


    return $total_rows;
}

我try 按照请求的顺序对字段重新排序并隐藏字段.

Subtotal Cart

推荐答案

要从管理订单合计行中隐藏原始小计行,请使用以下方法:

add_action('admin_head', 'admin_head_shop_order_inline_css' );
function admin_head_shop_order_inline_css() {
    global $pagenow, $typenow;

    // Targeting WooCommerce admin single orders
    if ( in_array( $pagenow, ['post.php', 'post-new.php'] ) && $typenow === 'shop_order' ) :
    ?><style>table.wc-order-totals tr:first-child{display:none;}</style><?php
    endif;
}

代码位于您的子主题的unctions.php文件中(或在插件中).经过测试,效果良好.

注:由于所有管理订单合计行的HTML都是以this file为硬编码的,因此您不能对它们进行重新排序.


要同时隐藏"envIO"发货总行,请将代码替换为:

add_action('admin_head', 'admin_head_shop_order_inline_css' );
function admin_head_shop_order_inline_css() {
    global $pagenow, $typenow;

    // Targeting WooCommerce admin single orders
    if ( in_array( $pagenow, ['post.php', 'post-new.php'] ) && $typenow === 'shop_order' ) :
    ?><style>
    table.wc-order-totals tr:first-child,
    table.wc-order-totals tr:nth-child(4){display:none;}
    </style><?php
    endif;
}

代码位于您的子主题的unctions.php文件中(或在插件中).经过测试,效果良好.

Php相关问答推荐

p a/a/p的x路径 Select ,但不是p somethext a链接/a或某些文本/p>

如何在Laravel Controller中存储文本区域值?

Laravel通过(扩展FormRequest类)方法验证表单请求

try 修改这个PHP代码如果语句在WordPress""

启用额外的WooCommerce产品库存位置

在ShipStation for WooCommerce中使用自定义订单项目元数据

WooCommerce:在 checkout 审核单和发票中显示定制产品数据

Sylius php -如何将购物车传递到小枝模板(Sylius模板事件)

如何实现对数据库表中多列的唯一约束?

当配置的URL为空时禁用Laravel Slack日志(log)记录

未定义的类型';PDF';在Laravel 8

在WooCommerce循环中添加子类别和产品之间的分隔符

扩展 WooCommerce 类触发未捕获错误:未找到WC_Coupon类

如何设置Mailersend PHP API 模板变量?

WooCommerce - 调用功能ID不正确.不应直接访问订单属性

PDO 和 SQL 查询结果中日期格式不同的原因可能是什么?

同时执行odbc_execute、odbc_fetch_row和odbc_result

使用循环和引用而不是递归创建分层/父子数组

Laravel 从嵌套数组的第二级获取最后一项

Laravel - 关联与设置观察者事件的 ID