Remove subtotal line from orders pages, email notifications and cart + checkout pages in WooCommerce(从WooCommerce中的订单页面、电子邮件通知和购物车+结账页面中删除小计行)
本文介绍了从WooCommerce中的订单页面、电子邮件通知和购物车+结账页面中删除小计行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从购物车、结账、收到的订单、订单详细信息和电子邮件中删除小计。我不想使用css,因为它不会从订单详细信息页面和电子邮件中删除引用。我已尝试此代码:
add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );
function adjust_woocommerce_get_order_item_totals( $totals ) {
unset($totals['cart_subtotal'] );
return $totals;
}
它不起作用,小计在购物车和结账页面上可见。
是否还有其他功能,或者我是否必须在我的活动主题下创建一个单独的WooCommerce文件夹,并从模板中删除任何对"小计"的引用。
推荐答案
1)所有订单页面和电子邮件通知(已收到订单、订单付款、订单查看和电子邮件)
您的代码工作正常,并从总计行中删除小计行:
add_filter( 'woocommerce_get_order_item_totals', 'remove_subtotal_from_orders_total_lines', 100, 1 );
function remove_subtotal_from_orders_total_lines( $totals ) {
unset($totals['cart_subtotal'] );
return $totals;
}
代码放在活动子主题(活动主题)的函数.php文件中。已测试并正常工作。
2)购物车和结账页面:
您需要to create a separate "woocommerce" folder under your active theme以下模板:
for Cart-cart/cart-totals.php
|删除第32行到第35行的代码块:
<tr class="cart-subtotal">
<th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
<td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
For Check Out-checkout/review-order.php
|删除第58行到第61行的代码块:
<tr class="cart-subtotal">
<th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
保存两个模板…您的工作完成了。
这篇关于从WooCommerce中的订单页面、电子邮件通知和购物车+结账页面中删除小计行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:从WooCommerce中的订单页面、电子邮件通知和购物车+结账页面中删除小计行


基础教程推荐
猜你喜欢
- php中的PDF导出 2022-01-01
- php中的foreach复选框POST 2021-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- Web 服务器如何处理请求? 2021-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01