扩展woocommerce_cart_item_price挂钩以反映订单和电子邮件的更改

时间:2020-05-26 13:58:46

标签: php wordpress woocommerce hook-woocommerce orders

我正在使用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 );

1 个答案:

答案 0 :(得分:0)

假设您正在寻找

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 );