I want to give a $50 discount to anyone with the coupon code I created. The coupon is for anything in the store. However the system is giving the discount based on each item in the cart. I can't use percentage because the prices vary. Here's the custom rule for flat discount with coupon. How do I change the amount to a flat rate of $50? If there is one item in the cart discount $50. if there is more than one item discount $50.
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Coupon code is always tested in lowercase -->
<xsl:if test="in/salesOrder/couponCodes[couponCode = 'free2']" >
<xsl:value-of select="-0.10 * in/this/salesOrderDetail/amount" />
The Storefront is Avalara certified for tax compliance. In normal accounting practice, a discount needs to be subtracted from something materially sold so that the appropriate tax due can be calculated for each product sold against its net final price after discount. This makes sense for the same reason you can't give a $50 discount if the user buys less than $50 as it will come to a negative total. A easy way is to check the order exceeds $50 subtotal and simply split the $50 discount proportionally to each sales order detail amount relative to the subtotal.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:variable name="SubTotalExclDiscounts" select="sum(in/salesOrder/salesOrderDetails/salesOrderDetail/amount)"/>
<xsl:if test="in/salesOrder/couponCodes[couponCode = 'free2'] and $SubTotalExclDiscounts > 50">
<xsl:value-of select="-50 * (/in/this/salesOrderDetail/amount div $SubTotalExclDiscounts)"/>
Thank you JT... Works great!