【发布时间】:2021-12-20 07:49:12
【问题描述】:
我在订单表中添加了 3 项自定义费用,但在发送给管理员/客户的电子邮件中,我想隐藏其中一项自定义费用。
查看屏幕截图:
其实我是用这个sn-p加了自定义费用的:
add_action( 'woocommerce_cart_calculate_fees','customfee1' );
function customfee1() {
$soustotalavecliv = (WC()->cart->get_cart_contents_total()+WC()->cart->get_shipping_total());
WC()->cart->add_fee( 'TOTAL', $soustotalavecliv );
}
add_action( 'woocommerce_cart_calculate_fees','customfee2' );
function customfee2() {
$retraitsubt = (WC()->cart->get_cart_contents_total()+WC()->cart->get_shipping_total());
WC()->cart->add_fee( 'A retirer', $retraitsubt*-1 );
}
add_action( 'woocommerce_cart_calculate_fees','customfee3' );
function customfee3() {
$total_minus_100 = (WC()->cart->get_cart_contents_total()+WC()->cart->get_shipping_total()) /2;
WC()->cart->add_fee( 'Acompte versé par CB', $total_minus_100 * -1 );
}
但在所有模板电子邮件中,我想隐藏“customfee2”。我设法用 CSS 代码隐藏了这一点。但以下代码仅适用于发送给管理员的 NEW ORDER EMAIL,而不适用于其他电子邮件。
function ymcode_hide_customfee2_row_with_css()
{
?>
<style>
tfoot tr:nth-child(5) {
display: none !important;
}
</style>
<?php
}
add_action('woocommerce_email_header', 'ymcode_hide_customfee2_row_with_css', 10, 0);
有什么建议吗?
【问题讨论】:
-
您好,抱歉,我还没有尝试您的代码。会尽快回复
标签: php wordpress woocommerce email-notifications fee