I am programmatically adding a discount to a Woocommerce order if they are a member as shown below:
function member_discount($cart) {
/* Code to check if user is a member here */
$memberdiscount = 0.05;
// Get total cart amount
$carttotal = $cart->cart_contents_total;
// Calculate numbered discount
$discount = $carttotal * $memberdiscount;
// Alter the cart discount total
$cart->discount_total = $cart->discount_total + $discount;
}
add_action('woocommerce_calculate_totals', 'member_discount');
However, when I buy a product worth £10 and the user is a member (thereby getting a 5% discount), the order shows the below, with no mention of why the discount has been applied:
Cart Subtotal £10.00
Order Total £9.50
What would be great is something like:
Cart Subtotal £10.00
Member Discount £0.50
Order Total £9.50
Or fooling woocommerce into thinking a coupon code has been applied:
Cart Subtotal £10.00
Coupon: Member Discount £0.50
Order Total £9.50
Does anyone know if this is possible?