【发布时间】:2018-03-15 09:19:29
【问题描述】:
我对在电子邮件和感谢页面中添加一行的代码有疑问。
add_filter( 'woocommerce_get_order_item_totals', 'bbloomer_add_recurring_row_email', 10, 2 );
function bbloomer_add_recurring_row_email( $total_rows, $myorder_obj ) {
$total_rows['recurr_not'] = array(
'label' => __( 'Rec:', 'woocommerce' ),
'value' => 'blabla'
);
return $total_rows;
}
我有一个功能可以在购物车中添加“Total excl. VAT”行:
<?php
global $woocommerce;
$frais = 1.01;
echo '<tr class ="totalht">
<th>'. __( 'Total HT', 'woocommerce' ) .'</th>
<td data-title=" '. __( 'Total HT', 'woocommerce' ) .' ">'
. wc_price( ( $woocommerce->cart->cart_contents_total * $frais ) + $woocommerce->cart->shipping_total ) .'<span class="ht-panier">HT</span></td>
</tr>';
?>
运行良好:https://prnt.sc/irglky
但是当我修改第一个函数时:
add_filter( 'woocommerce_get_order_item_totals', 'bbloomer_add_recurring_row_email', 5, 2 );
function bbloomer_add_recurring_row_email( $total_rows, $myorder_obj ) {
global $woocommerce;
$frais = 1.01;
$price_excl_vat = wc_price( ( $woocommerce->cart->cart_contents_total * $frais ) + $woocommerce->cart->shipping_total );
$total_rows['recurr_not'] = array(
'label' => __( 'Total HT :', 'woocommerce' ),
'value' => $price_excl_vat
);
return $total_rows;
}
它不起作用on the Thank you page
但它正在工作on email...
有人可以解释一下为什么它可以在电子邮件上运行,但在“感谢页面”中却不行?
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce orders