2
我正在嘗試計算運費,具體取決於使用Fedex Gem https://github.com/jazminschroeder/fedex購買的產品的總數量。我得到的速度,但我有不同的包選項,其實3。當數量爲1(小)時爲第一個,當數量爲2(中)時爲第二個,當數量爲3或4(較大)時爲第三個。Fedex gem,倍數套餐
def packages_types
packages = []
if @order.quantity >= 4
packages << { :weight => {:units => "LB", :value => @order.case_weight},
:dimensions => {:length => 8, :width => 1, :height => 7, :units => "IN" } }
elsif @order.quantity == 2
packages << { :weight => {:units => "LB", :value => 21},
:dimensions => {:length => 1, :width => 2, :height => 7, :units => "IN" } }
elsif @order.quantity == 1
packages << { :weight => {:units => "LB", :value => 10},
:dimensions => {:length => 1, :width => 2, :height => 2, :units => "IN" } }
end
end
所以,如果客戶訂購5數量。這將是4個(大)和1個小包裝的包裝。我用的模想...
你在這裏有什麼問題? – MrYoshiji
問題是...取決於數量是否超過4 ...如果數量是5,如何選擇使用大包裝和1小包裝 – Jose14