扩展 woocommerce_cart_item_price 挂钩以反映订单和电子邮件的变化
Expands woocommerce_cart_item_price hook to reflect the changes in order and email
我正在使用 WooCommerce,我在购物车和结账页面上添加了一些价格显示和税收代码。而且效果很好。
我的问题是我需要什么样的操作过滤器才能在订单创建后显示它并在客户发送的电子邮件中显示它
收到?
这是我的代码,它在结账和购物车页面上显示折扣和原价。
function my_custom_show_sale_price_at_cart( $old_display, $cart_item, $cart_item_key ) {
$product = $cart_item['data'];
if ( $product ) {
return $product->get_price_html();
}
return $old_display;
}
add_filter( 'woocommerce_cart_item_price', 'my_custom_show_sale_price_at_cart', 10, 3 );
假设您正在寻找这个
function filter_woocommerce_order_formatted_line_subtotal( $subtotal, $item, $order ) {
// The instance of the WC_Product Object
$product = $item->get_product();
if ( $product ) {
return $product->get_price_html();
}
return $subtotal;
}
add_filter( 'woocommerce_order_formatted_line_subtotal', 'filter_woocommerce_order_formatted_line_subtotal', 20, 3 );
我正在使用 WooCommerce,我在购物车和结账页面上添加了一些价格显示和税收代码。而且效果很好。
我的问题是我需要什么样的操作过滤器才能在订单创建后显示它并在客户发送的电子邮件中显示它 收到?
这是我的代码,它在结账和购物车页面上显示折扣和原价。
function my_custom_show_sale_price_at_cart( $old_display, $cart_item, $cart_item_key ) {
$product = $cart_item['data'];
if ( $product ) {
return $product->get_price_html();
}
return $old_display;
}
add_filter( 'woocommerce_cart_item_price', 'my_custom_show_sale_price_at_cart', 10, 3 );
假设您正在寻找这个
function filter_woocommerce_order_formatted_line_subtotal( $subtotal, $item, $order ) {
// The instance of the WC_Product Object
$product = $item->get_product();
if ( $product ) {
return $product->get_price_html();
}
return $subtotal;
}
add_filter( 'woocommerce_order_formatted_line_subtotal', 'filter_woocommerce_order_formatted_line_subtotal', 20, 3 );