Skip to Content
Former Member
Dec 11, 2014 at 11:21 AM

Why is a voucher application setting the free shipping?


We found this interesting behaviour after having applied a voucher on a cart (both by HMC and from our code)


What happens is that the cart gets a free shipping, even if the voucher has not free shipping included.

By decompiling this incredibly well coded part, we found this code that indeed sets the free shipping, but we cannot really understand why.

 public VoucherValue getVoucherValue(AbstractOrder anOrder) {
     Iterator discounts = anOrder.getDiscounts().iterator();
     boolean found = false;
     boolean applyFreeShipping = false;

     while(discounts.hasNext() && !found) {
         Discount applicableValue = (Discount);
         if(applicableValue instanceof Voucher) {
             Voucher resultValue = (Voucher)applicableValue;
             if(resultValue.isApplicable((AbstractOrder)anOrder) && resultValue.isFreeShippingAsPrimitive()) {
                 if(resultValue.equals(this)) {
                     applyFreeShipping = true;

                 found = true;

Any ideas?