1 回答

TA貢獻(xiàn)1834條經(jīng)驗(yàn) 獲得超8個(gè)贊
由于您可以通過(guò)鉤子訪問(wèn)該$order對(duì)象woocommerce_get_order_item_totals,因此您可以以相同的方式應(yīng)用它。
所以你得到:
// After order table
function action_woocommerce_email_after_order_table( $order, $sent_to_admin, $plain_text, $email ) {
// Get used coupons
if ( $order->get_used_coupons() ) {
// Total
$coupons_count = count( $order->get_used_coupons() );
// Initialize
$i = 1;
$coupons_list = '';
// Loop through
foreach ( $order->get_used_coupons() as $coupon ) {
// Append
$coupons_list .= $coupon;
if ( $i < $coupons_count )
$coupons_list .= ', ';
$i++;
}
// Output
echo '<p><strong>Купон:</strong> ' . $coupons_list . '</p>';
}
}
add_action( 'woocommerce_email_after_order_table', 'action_woocommerce_email_after_order_table', 10, 4 );
// Display on customer orders and email notifications
function filter_woocommerce_get_order_item_totals( $total_rows, $order, $tax_display ) {
// Get used coupons
if ( $order->get_used_coupons() ) {
// Total
$coupons_count = count( $order->get_used_coupons() );
// Initialize
$i = 1;
$coupons_list = '';
// Loop through
foreach ( $order->get_used_coupons() as $coupon ) {
// Append
$coupons_list .= $coupon;
if ( $i < $coupons_count )
$coupons_list .= ', ';
$i++;
}
// Output
$total_rows['recurr_not'] = array(
'label' => __( 'Купон:', 'woocommerce' ),
'value' => $coupons_list,
);
}
return $total_rows;
}
add_filter( 'woocommerce_get_order_item_totals', 'filter_woocommerce_get_order_item_totals', 10, 3 );
- 1 回答
- 0 關(guān)注
- 124 瀏覽
添加回答
舉報(bào)