Upcoming Coupon Changes in WooCommerce 2.3

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.

 


Keep yourself in the loop!

Sign up for the WooCommerce developer newsletter:
Hidden
Hidden
Hidden


34 responses to “Upcoming Coupon Changes in WooCommerce 2.3”

  1. Changing coupons like that is going to cause massive issues for people in Australia.

    Australians who buy retail (from Australian stores – online or otherwise) don’t even know what the pre tax price is.

    And any discount to a price is always off the total price – not pre tax.

    So Australian stores aren’t going to be able to upgrade until either –
    A) you implement a checkbox to apply to total price (effectively the reverse of what was previously implemented)
    B) someone else creates a plugin / snippet to have coupons apply to total pricing.

    Could you reply to this comment and let the Australian store owners what they should do as a matter of priority please.

    Simon

    1. I agree with Simon, the same in Italy (and I presume the whole EU) !
      Private clients, not business, don’t care about taxes (TVA), they always see the total price.

    2. Or (though I doubt likely) even better just leave it the way it was so I don’t have to change anything or educate clients and make amendments to their sites.

      Ps my email was incorrect in the original post, it’s correct in this one.

    3. > And any discount to a price is always off the total price – not pre tax.

      Maybe it would help if I clarify how ‘before tax’ coupons work with ‘prices inclusive of tax’. I don’t think it will be an issue for you. And if it is, you may be doing it wrong currently.

      Lets take a $10 product, inc tax. Tax rate for this example can be 10%.

      Ignoring coupons for the moment, that would give us a $10 sale with $0.91 tax (the sum for that is 10-(10/1.1)).

      Now lets use a $5 coupon. This time we’d have 10 – 5 = $5 sale, and then we’d work out tax at being $0.46.

      In the previous system, with an after tax coupon you’d be charging the same amount ($5) but tax would be miscalculated as 0.91 still, since that would be calculated before discount. This is wrong and thus removed.

      I think the confusion stems to the ‘before tax’ wording; we’re talking about where the discount and tax calculation take place, we are not talking about which price gets discounted initially. Another ++ for removing it.

      @Gabriele I am in the UK and our implementation is correct.

      1. @Mike – perhaps the wording had me confused.

        If it works the way you put forward then that makes sense at a product level.

        Would it the. work the same way on total order amounts as well?

        That’s something I’ve had trouble with in the past – if a total order is $100 inc tax and a $10 coupon is applied to the order then the order total will be $90 inc tax of 8.18 as tax is applied to the overall order.

        … assuming all items are taxable – which sometimes they aren’t eg credit card fees. If there were credit card fees of $2 (and that was fixed for the sake of the example) on the above order the total would be $90, but tax would be only on $88 so $8 tax on the total order.

        Also we use store credit as per @Doug – it would be used toward the total order amount – not pretax. Eg $100 order inc tax paid for with a $100 store credit would yield a nil balance (ie not a $9.09 credit for unpaid tax component).

        1. The store credit implementations I am aware of work like the before-tax coupons. So the actual discount is reflective of whether prices include tax or not, to avoid having to pay tax when there is a 100% discount.

          > That’s something I’ve had trouble with in the past – if a total order is $100 inc tax and a $10 coupon is applied to the order then the order total will be $90 inc tax of 8.18 as tax is applied to the overall order.

          A 100 – 10 order would be 8.18 tax. If you had extra non-taxable fees, these would need adding via the fee system where taxes are optional. Regardless of whether its a product or ‘cart’ discount, the discounts are applied at line-item level to accommodate this.

  2. I agree with Simon. The same applies in New Zealand – prices for all retail consumer goods are required to be displayed tax-inclusive, and any discounts would be presumed to apply to the after-tax price. Any company that advertised a discount coupon and then only applied that to the pre-tax price would be considered deceptive and probably to have breached our Fair Trading Act.

    However, I wonder if the intention is for the original functionality to be immediately available as a paid plugin, so that we will now have to pay extra for what was previously included functionality?

    1. See the reply to Simon above.

  3. The coupon system can be used to offer different kinds of things with different tax requirements, depending on what extensions may be installed. For example, WooThemes sells the Smart Coupons extensions, which adds the ability to issue gift certificates, vouchers, and store credit.

    In the USA, we would apply a coupon before tax is calculated, as was described. That makes sense because the product is being sold at a lower amount and tax is based on that.

    However, a store credit is treated more like cash. It is sort of like a payment being applied toward the order rather than a discount of an item. So sales tax must be calculated before that credit is applied.

    Both of those scenarios are all handled by the coupon system so it sounds like this change would take away the ability to handle the latter correctly.

    1. > However, a store credit is treated more like cash. It is sort of like a payment being applied toward the order rather than a discount of an item. So sales tax must be calculated before that credit is applied.

      Do you have anything to back that up? I don’t know if you can say they are “like” cash unless they are cash.

      I cannot find any particular US examples, but I think in logical sense these should still be handled before tax. Why? Sales tax was already taken for the original sale. Giving store credit isn’t a refund.

      1. @Mike,

        Gift codes should follow the same rules as coupon codes (After WC 2.3).

        It’s illegal to charge taxes on an amount greater than what the customer has paid for an item. If the customer didn’t pay the full amount, you’re not allowed to collect sales taxes on the full amount.

        You’re getting different stories from different people. But the confusion here is being caused by the fact that when generating the code, the name “Gift Certificate” and “Store Credit” is used interchangeably.

        “Store Credit” should be same as cash, as Doug explained, and hoe it is now. (Applied after tax)
        “Gift Certificates” should be gifts. (Applied BEFORE tax).

        Practical example for a “Store Credit”:
        A customer has paid a total of $20 for a product. After using it for a year it breaks due to a defect. The item is no longer carried in stock. The store owner should be able to give that customer a store credit of $20 to use towards any replacement item they want. (currently possible)

        Practical example for a “Gift Certificate”:
        A store owner wants to gift an item worth $25 to a reviewer (unknown state), and shipped with a priority service ($10), instead of the basic “free shipping” option. The store owner should be able to generate a $35 “Gift code” for the recipient, and not worry about them being charged sales taxes on an item they didn’t pay for. (Currently not possible)

        At the very least, shop owners should have the option to let the “Store Credit/Gift Certificates” code apply before or after taxes. I hope that this helps clarify what everyone is complaining about.

        Looking forward to your response, and hopefully a solution.

        Thanks!

        1. Core only uses the terminology ‘coupon’. Never mentions gift certificates or store credit.

          1. @Mike. Thanks for that insight, although not exactly a response to what I had written above. As explained earlier, store owners need to be able to issue “Gift Certificates” that get applied before taxes are calculated. This is a necessary feature that is required for a normal operation of an online store. When can we expect this to be added to Woocommerce?

            Thanks.

          2. I don’t know if you’re reading into this post wrong, but ALL coupons are applied before taxes are calculated. We’re handling this fine.

            Anything else (e.g. store credit) is extension territory.

          3. The coupons are being applied correctly. I’m referring to the gift certificates. I’m using the smart coupons extension to generate gift certificates. Smart coupons is made by Woocommerce. I’m not sure who else to be speaking to for this, if not you.

            I have not yet been able to find any extensions that can generate gift certificates that get applied prior to calculating taxes. If you know of any, please let me know. If not, can you please tell me if there are any plans to update the “Smart coupons” extension so that it can do that?

            Thanks,
            Rambod

  4. @Doug – When I use gift certificates in the states they don’t charge sales tax. Last year I used a $200 Best Buy gift certificate to buy $200 in App Store gift certificates. No tax.

  5. @Mike, You are correct in that we need to make sure not to double tax.

    However, when gift cards or certificates are sold they are not taxed in the United States. It is treated as an exchange of cash for cash equivalent. You are then taxed on the purchase of any items, based on the tax rates for those items and the tax rates of the state that has jurisdiction for that purchase.

    That is important because you could buy a gift certificate in one state and use it for a purchase in another state with a different tax rate. Or you may use a gift certificate to buy items that have different tax rates. For example, some states have a different tax rate for food items vs non-food items.

    The only way that can work out is if the tax is applied on the items purchased with the gift certificate treated as cash. I’ve quoted the rules from a few states below to show that is the case. As far as I know, this is the same in every state.

    @Patrick, You were using a gift certificate (cash equivalent) to purchase more gift certificates (cash equivalent) so tax would not be charged. You would be taxed when using either of those to later purchase tangible goods, just like if you purchased them with cash. Depending on the state having jurisdiction, you may or may not be charged tax if you use them to purchase digital, virtual goods.

    Samplings from a few states’ rules:

    Pennsylvania
    Gift certificates are treated the same as cash. At the time of purchase, the gift certificate is not subject to sales tax. If the gift certificate is used to purchase taxable items, sales tax will be charged in conjunction with this transaction.
    https://revenue-pa.custhelp.com/app/answers/detail/a_id/1921/~/is-the-sale-of-a-gift-certificate-taxable

    Washington
    Taxes are due when the gift card/certificate is redeemed by the holder. When the card/certificate is used, the taxes due on the sale depend on the nature of the item or service purchased
    http://dor.wa.gov/Content/GetAFormOrPublication/PublicationBySubject/TaxTopics/GiftCertLayaway.aspx

    Connecticut
    Cash equivalents are items purchased that entitle a person to redeem them in the future to receive tangible personal property or services. Examples of cash equivalents include, but are not limited to dine out cards, entertainment coupon books, vouchers, gift certificates, and trading stamps (whether or not the items are called coupons). Cash equivalents are deemed to be intangible rights to acquire tangible personal property or services in the future and thus are not taxed when acquired. However, the redemption of a cash equivalent is taxable based on the retail price of the tangible personal property or services for which the cash equivalent is redeemed.
    http://www.ct.gov/drs/cwp/view.asp?A=1511&Q=395808

    Illinois
    The sale of a gift certificate is not subject to Illinois sales tax. A gift certificate is an ‘intangible’ which is not taxed under the Retailers [sic] Occupation Tax Act. 86 Ill. Adm. Code 130.120(a). See also ST 02-0036-GIL (Feb. 7, 2002). Rather, if a gift certificate is redeemed for tangible personal property to be used in Illinois, Use Tax is due on the selling price of the tangible personal property purchased, whether partially or wholly funded by the gift certificate. ST 06-0125-GIL (Jun. [sic] 7, 2006), ST 02-0036-GIL (Feb. 7, 2002), ST 95-0331-GIL (Aug, 10, 1995).
    http://tax.illinois.gov/LegalInformation/LetterRulings/st/2004/sg040192.pdf

    1. Do you use an extension for gift certs? If the above turns out to be the case, perhaps this should be handled in the gift cert extension. I’d much prefer that than keeping the 2 levels of coupon we have in 2.2. cc @patrick

      1. Yes, I’m currently using the Smart Coupons extension for gift certificates and store credit. I believe the PDF Product Vouchers extension would also be affected by this. I’m sure there are other extensions outside of the WooThemes store that would have to be updated as well. I know there are several over at Code Canyon, for example.

        1. I’m going to double check with Nirav, but I think that extension already handles this outside of the coupon system.

          1. Were you ever able to confirm this?

        2. Doug – did you get a reply. Here in Canada we have similar issue where a gift card needs to be applied after tax.

          Mike – we have a customer selling gift cards from his Brick and Mortar facility that don’t get taxed at the time of sale. But when the customer makes a purchase on the site and applies the coupon code we are supposed to apply the value after total of the shopping cart including tax… so purchase of 100+ tax 13% = 113. now subtract $100 (gift card value) = total payable = $13.

          1. Use a gift card/certificate plugin – coupons are not gift cards.

  6. There is also a TON of custom plugin code written for various sites operating the USA and other countries to handle “same as cash” gift codes / store credit issuance via coupon codes.

    Sometimes the overall operation of such a coupon code needs to be changed due to changes in localized tax laws. Right now that is easy: Change the setting on the coupon for when to apply the credit: before tax or after tax.

    The overall problem, in the USA at least, is that government is structured so that there is a federal level with laws, then state level with laws, then counties with laws, then cities or municipalities with laws – and depending on the upstream laws the downstream entities may or may not have the right make changes. So for example, in one city in the same county a law might read “X” for example, while 1 mile down the road in another city that same law might have been amended to ready “Y” because that’s what the city decided as there was nothing in upstream laws preventing them from amending.

    It’s probably a good idea to leave the setting in place otherwise legislators might do something that causes an entire site to operate incorrectly resulting in some seriously pissed off WooCommerce users. In other words, give the site operators a choice via settings, even if you change the default behavior in the core code, at least the site ops can make a simple setting adjustment to meet ever changing legal landscape.

    The overall situation is this from a site operator’s perspective: Yes a developer can go in and change code, and subsequently charge a customer for that work. And invariably they get upset about having to constantly spend money on things that ought to exist in a simple setting – not to mention the fact that a developer can’t always adjust their code immediately. Which of course reflects badly on WooCommerce itself, particularly when they’ve been using a setting for 3 years that suddenly vanishes…

  7. Hello,

    I’m glad that coupon system will be looked at on 2.3.

    I think that coupon might be thought as “negative products (or part of products)” from an accounting point of view : If you do not do so, your book writing is just not balanced. Just as the refunds are “negative orders”. It would be really easier to deal with.

    In fact, even if you apply it after tax, you still have to calculate the tax part of your coupon value (the way it’s calculated is just math but the law is the law !)… It’s tricky but possible even with WC2.2.

    I also have a question : today I tested before tax and after tax coupons and when coupon is before tax, you have exactly the same price if you chose to apply on order or cart. But when coupon is after tax it includes the shipping. Do you consider shipping as a tax so it doesn’t impact the result when before tax ?

    Thank you very much for the nice work by the way !

  8. John Arcadian Avatar
    John Arcadian

    So, the major issue that this is causing for us is that coupons for shipping no longer work at all. We thought we could get around it by offering store discounts, but that doesn’t work. Here is where this update fails and needs addressed.

    We create coupons to give $5.00 off shipping.
    When they were applied after taxes, it worked perfectly.
    Now, they apply before taxes.
    Customers can still use free shipping, but we cannot defray the costs of shipping to customers outside the US.

    We need some way to apply these coupons to the shipping amount, not just to the end of the cost calculations.

    1. Shipping is taxable. Doing this would have results in incorrect taxes charged..

  9. John Arcadian Avatar
    John Arcadian

    So how do we offer discounts on shipping to our customers? I.E. We don’t want to give free shipping to international customers, but we do want to help defray the cost. If we give them a regular coupon, they can buy something else in our store, but they still incur a huge shipping cost or we take a HUGE cut on shipping.

    I understand the legal perspectives and other issues, but it removed a whole slew of functionality. Even store credits apply this way, so we can’t just switch those coupons to a store credit, because they still can’t apply it to shipping.

  10. Hi Mike,

    I don’t think that there is a solution until today and you guys are just ignoring the european customer base.

    So, when will I be able again to apply a coupon to the order total. As explained by many in the comments and all over the web, thats exactly what is needed.

    If I have a 100€ Total, different products with different tax rates are in that order, and a 10€ coupon, total needs to be 90€.

    Thanks a lot for your quick reply.

    1. That’s what happens with tax inclusive prices. Don’t forget the lead dev is in Europe :p

      1. Hi Mike,

        I thought this is the offical dev blog of woocommerce. So, I was expecting a more serious answer. Like “We change that in version X.x” Or some kind of solution. Not just explaining the current state and that it is not working the way we, the customers in europe, need it to work.
        If your answer is “I dont care. Thats how it is.” Let us know.
        Maybe we, the customers in europe, just need to start a pedition and get a little bit louder and just leave woocommerce and change to a different platform.

        1. As I said, if you use the “I will enter prices including tax” setting that’s how coupons work. Example, £100 product, £10 coupon. Customer charged £90. It has always been this way.

  11. Hey @Mike, I just noticed a serious bug with the coupons.
    Coupon codes do not update the usage count when applied on pre-orders!
    I don’t know if this is just my site’s install, or an issue with everyone. But I’ve updated all my plugins and themes to their latest version, and still this issue persist. Also, all my child-theme files are up to date with WC files.

    I’m having a big sale next week for an item on pre-order. I will be sending unique coupon codes to a large group of people. Each coupon has a limit of 1 usage.
    I was just doing some tests, and it looks like if you apply the coupon code on a pre-order item, it works and the discount is applied. The Sales goes through, no problem. But the usage count still shows zero. So the customer can go back to the store again and buy as many other pre-order products as they like with the same unique code.

    If the same code is then used once on an available product, the usage does update, and it can’t be used again.
    My guess is that the usage is being updated every time an order goes into the “processing” stage. But pre-orders don’t go to this stage until they are available. I don’t know, I’m just guessing that might be why.

    Please let me know if there’s a quick fix for this issue without having to wait for the next update? I need to email these coupons to our partners today. Any help would be much appreciated.

    Thanks!

    1. Ok, FYI, I can confirm that the issue is cased by the fact that coupons are being counted when the order status has been changed to “processing”. I just manually changed the status of one of my test pre-orders from “pre-ordered” to “processing”, and the coupon used for that order automatically updated to count the usage. That seems to be the culprit.

      I’ll need to get this fixed right away. I hope you can help me find a solution.

      Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *