Reputation: 1180
I want to show the discounted price on checkout page after applying the coupon, discounted price is showing on cart page and payment gateway also but I want to show on checkout page also, so customer can easily understand they have applied coupon.
is there any way to show discounted price after applying coupon.
With this hook I am trying to get discounted price on checkout page
function woocommerce_order_review() {
$totalp = $woocommerce->cart->get_cart_subtotal();
$totaldisc = $woocommerce->cart->get_total_discount();
$resultp = $totalp - $totaldisc;
print_r($resultp);
}
add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
Upvotes: 0
Views: 3538
Reputation: 1180
I have solved my question below is the code I just replicated review-order.php from
wp-content/woocommerce/checkout/review-order.php
in my themes folder woocommerce
mytheme/woocommerce/checkout/review-order.php
and find this class class="product-total" replace whole php of this td with below mentioned code
<?php function remove_currency($price) {
return (double) preg_replace('/[^0-9\.]+/', '', $price);
}?>
<?php
$total = remove_currency(apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ));
$discount = remove_currency(apply_filters( 'get_total_discount', WC()->cart->get_total_discount( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ));
echo $total-$discount;
?>
Please correct me if I am wrong Thank you
Upvotes: 0
Reputation: 1078
You can customize woocommerce/templates/checkout/review-order.php template and show discounted price as per your requirement by placing it under your themes folder.
You have cart items loop in review-order.php
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
with this content.
in this you will have subtotal in last table cell. There you can show the discounted price.
Or alternatively you can implement this hook. "woocommerce_cart_item_subtotal"
Upvotes: 2