Reputation: 303
I am using WooCommerce and I added some code for price display and tax on cart and checkout page. And it works very good.
My question here would be what kind of action filter do I need to also display it once the order is created and to display this also in the email that the customer receive?
So this is my code that is displaying discount and original price on checkout and cart page.
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 );
Upvotes: 1
Views: 3886
Reputation: 29640
Assuming you're looking for this
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 );
Upvotes: 1