We found this interesting behaviour after having applied a voucher on a cart (both by HMC and from our code)
voucherFacade.applyVoucher(voucherCode);
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)discounts.next();
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?