1 4 package com.openedit.store.shipping; 5 6 import java.util.Iterator ; 7 8 import org.openedit.money.Money; 9 10 import com.openedit.store.Cart; 11 import com.openedit.store.CartItem; 12 13 14 18 public class PriceBasedShippingMethod extends BaseShippingMethod 19 { 20 public Money getCost(Cart inCart) 21 { 22 Money totalPrice = getHandlingCharge(inCart); 23 totalPrice = totalPrice.add(getCost()); 24 25 return totalPrice; 26 } 27 public boolean applies(Cart inCart) 28 { 29 double subTotal = inCart.getSubTotal().doubleValue(); 30 31 35 for (Iterator iter = inCart.getItemIterator(); iter.hasNext();) 36 { 37 CartItem cartI = (CartItem) iter.next(); 38 String method = cartI.getProduct().getShippingMethodId(); 39 if ( method != null ) 40 { 41 subTotal = subTotal - cartI.getYourPrice().doubleValue(); 43 } 44 } 45 46 if ( getLowerThreshold() == null || 47 Money.ZERO.equals(getLowerThreshold()) || 48 getLowerThreshold().doubleValue() <= subTotal) 49 { 50 if (getUpperThreshold() == null || 51 getUpperThreshold().doubleValue() >= subTotal) 52 { 53 54 return true; 55 } 56 } 57 return false; 58 } 59 60 } 61 | Popular Tags |