Show discount

<?php

// ceramic
/**
 * Show applied amount of discount
 */
function discount_notice() {
	global $woocommerce;

	if ( ! is_cart() && ! is_checkout() ) { // Remove partial if you don't want to show it on cart/checkout
		return;
	}

	foreach($woocommerce->cart->cart_contents as $content) {

		$quantity = $content['quantity'];

		if(isset($content['discounts']['applied_discounts'])) {

			foreach ($content['discounts']['applied_discounts'] as $discount) {
				$price_base = (float)$discount['price_base'];
				$price_adjusted = (float)$discount['price_adjusted'];
				$discount = $price_base - $price_adjusted;
				$total_discount = ($discount * $quantity);
			}
		}

		if($total_discount > 0) {
			wc_add_notice( sprintf(__('Er is %s korting verrekend!', 'ceramicnature'), wc_price( $total_discount )) );
		}
	}
}
add_action('wp', __NAMESPACE__ . '\\discount_notice');
Last Updated:
Contributors: Niek Vlam, Suite Seven