For 2.3, aside from UI, we’ve been looking at some long standing issues. One of these issues related to the display of coupons when prices include tax (#4848). Although complex, this issue has been resolved in 2.3 without too much change, however, this also got us looking at this point raised by Samuel Aguilera:

Apply discounts after taxes is not legal. Discounts must be always applied before taxes, is the law, not user preference.

If you’re not aware, up to now the coupon system has always had an option at coupon level called “apply before tax” which, as stated, makes sure a coupon is calculated before tax at line-item level. Leaving the box unchecked would take the discount off after all taxes – so in reality we had 2 different types of coupons (before tax – cart, after tax – order) each with their own methods and display related functions.

In 2.3 we’ve decided to simplify this down, have 1 set of coupons, and always apply them before-tax. See #6830.

So What Has This Been Changed?

  • Apply Before Tax option removed from coupons
  • WC_Cart::get_coupons() which used to allow you to pass either ‘cart’ or ‘order’ has deprecated the type arg. If you pass in ‘order’ an empty array is returned.
  • WC_Cart::remove_coupons() same as above.
  • Deprecated some coupon methods in the cart and orders class:
    • WC_Cart::get_order_discount_total()
    • WC_Cart::apply_cart_discounts_after_tax()
    • WC_Cart::apply_product_discounts_after_tax()
    • WC_Cart::get_discounts_before_tax()
    • WC_Cart::get_discounts_after_tax()
    • WC_Abstract_Order::get_cart_discount()
    • WC_Abstract_Order::get_order_discount()
    • WC_Abstract_Order::get_cart_discount_to_display()
    • WC_Abstract_Order::get_order_discount_to_display()
  • $discount_total variable in cart class is deprecated (was after tax discount total) and will always be 0.
  • templates/cart/cart-totals.php has been edited to remove the after-tax discounts
  • templates/checkout/review-order.php has been edited to remove the after-tax discounts
  • Removed the edit ‘discount’ row from the edit orders panel in the backend – discounts are applied per line item (before tax!)

WC_Cart::get_total_discount() should be used if you need to get the discount amount, instead of the deprecated methods. This method exists in 2.2.

WC_Cart::get_discount_to_display() should be used to display the discount amount. This is a new method in 2.3

What Theme Developers Need to Update

Themes will need to update their template files, namely:

  1. templates/cart/cart-totals.php
  2. templates/checkout/review-order.php

They will need to remove the second coupon/discounts loops (order level coupons). Failure to update won’t break anything however, it will just show a deprecated notice.

What Plugin Developers Need to Update

Remove the use of dedicated methods, and avoid accessing properties directly where possible. This update has deprecated methods and thus shouldn’t ‘break’ plugins, but it will render some functionality useless, such as code which checks for after-tax discounts.

If you do notice something not backwards compatible (in that it causes error) will let us know asap.