on 2014 Dec 11 11:21 AM
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?
This looks like a bug. It finds only vouchers with free shipping.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.