0

I wondered in anyone could help me figure out how to display the coupon description underneath the coupon title in a WooCommerce cart? For example the title is the coupon code (COUPONCODE1234) but it would be useful if underneath or immediately after it displayed how much of a discount this provides i.e. '15% OFF'.

Here's the theme I'm using. You'll need to add a product to the cart to view the cart pane: http://demo.lollum.com/nantes/shop/shop/

I've tried the solution underneath but it doesn't work :( Display coupon description woocommerce

Hope someone can help point me in the right direction!

Community
  • 1
  • 1
Sarah B
  • 35
  • 7

1 Answers1

0

Assuming that you are using WooCommerce coupon and discount type is "Cart % Discount".

You can use the " woocommerce_cart_totals_coupon_html " filter to display the discount percentage after the coupon code on cart page.

function my_test($value, $coupon)
{
    if($coupon->discount_type == 'percent' && !empty($coupon->coupon_amount))
    {
        $amt = "<p>{$coupon->coupon_amount}% OFF</p>";   
    }

    return $value.$amt;
}
add_filter('woocommerce_cart_totals_coupon_html','my_test',10,2);

It will display the discount as shown in an image.

Cart Page

Domain
  • 11,562
  • 3
  • 23
  • 44
  • Thanks so much!! I was using Product % Discount but I swapped it to Cart % Discount, added your code and it worked....thanks so much, you're a star! :) – Sarah B Nov 20 '15 at 20:43