blog logo
[ultimatesocial count="true" networks="linkedin,facebook,twitter" url="" skin="minimal"]

Customizing Tax on Promotions in Demandware

Jennifer Madden • April 24, 2015

Deal of-the-day services, widely popularized by the company Groupon, are a hit among consumers and retailers alike. Thmed240053ey offer shoppers a chance to access exclusive offers at attractive prices, and enable retailers to draw in new business and gain increased visibility. If you’re going to implement such a service for your online business, there are a few things you have to keep in mind, one being calculating tax on these promotions.

There are various eCommerce sales tax rules that surround promotions, and it’s important to make sure you’ve got them right. A recent requirement on one of our clients’ Demandware storefront implementations was to enable customers to checkout with Groupon-type coupons, and our client needed us to customize how tax is calculated on these promotions.


Here’s how we did it:

  1. Set up custom attributes for the promotion

The first step was to modify the promotions object by adding custom attributes. We set up the following:

  • IsGroupon – a Boolean value that would indicate if the promotion was a Groupon promotion and needed to be evaluated as such
  • GrouponTax – a set of strings to determine what would be taxed, i.e. PRODUCT, PRODUCTANDSHIPPING, COUPON, COUPONANDSHPPING.
  • GrouponPrice – the price the customer paid for the coupon
  • GrouponValue – the value of the Groupon
  1. Adjust the amount to be taxed based on Groupon Promotion business rules

The Groupon promotion was set up with attributes that differentiated the promotion from others. That way we could determine what exactly needed to be taxed according to Groupon rules.

  1. Adjust the dollar amount to be taxed when tax is calculated

The next step was to evaluate the basket line items for price adjustments and if a Groupon type promotion existed, we would modify the amount that was sent to the tax service request.

An example of a typical Groupon promotion might be as follows:

Promotion.grouponPrice = 25.00

Promotion.grouponValue = 50.00

Promotion.grouponType =  Yes

Promotion.grouponTax = PRODUCTANDSHIPPING

So when processing the items in the basket and looking for price adjustments (promotions), the code to send the tax request would evaluate price adjustments and make changes accordingly to the totals to be taxed before calling the tax service.  If the ‘grouponTax’ value was set to PRODUCT, then shipping would not be taxed and zero amounts would be passed on.  If the ‘grouponTax’ value was GROUPON then the Groupon price would be taxed instead of the price of the product so the value of the amount to be taxed was adjusted before the service call was made.

Promotion Evaluation Management

One helpful way to evaluate promotions on the fly was to setup a promotion info object that would store all of the values from the promotion custom attributes and then use that object to make tax decisions quickly.  This made for much cleaner, more concise code in addition to setting the amount to be taxed before calling the tax service.  For each price adjustment in the basket, a promotion info object would be instantiated and values set so that the object would set the amount to be taxed and whether to tax shipping or not.  The promotion info object was only set up if the promotion was of type Groupon.  All other promotions would be treated in the default manner.

Promotions Setup

For setting up a promotion and a campaign, the client would determine if it was a Groupon promotion.  If GrouponType was false, then the promotion would process normally.  If the GroupType was true, then the additional attributes would need to be set up to determine the business rules of the promotion.  By setting up the promotion to initiate its rules, little code had to be modified.  In the end, only the tax request object was modified for what amounts should be taxed.

Tax Response

We did discover one caveat—when the tax response is returned, there may be default behavior set up for applying the tax to the line item.  In our scenario, the tax rate was used to apply tax on the line item, but when tax amounts are modified on the fly, the tax rate is not the correct value and to fix this, the response needed to apply the tax amount in lieu of the tax rate.

Now you have the tools to appropriately customize tax on your promotions.

Please contact us to learn more about how LYONSCG and Demandware solutions for your eCommerce site.


Jennifer Madden is a Senior Applications Engineer  on the LYONSCG eCommerce Implementation team, and has been working with Demandware since March 2011.  Jennifer is a certified Demandware Developer and started her career in web development in 1999 launching a local television station web site.

Jennifer Madden

About the author

Jennifer Madden

Subscribe to our blog

Let's discuss the next step in your commerce journey.

XSchedule a meeting