Sha256: a070ebf7bcb5ebe372d60de4ef8e02a75010800b4509ab627b0db2c4913324ae

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module ShipmentsHelper
  # Creates a radio button to represent a choice of shipping method.  The choice will be disabled if for some 
  # reason the rate is nil (perhaps the web service didn't return a quote for that method for some reason.)
  def shipping_radio(shipping_method, order)
    cost = shipping_method.calculate_shipping(@order)    
    checked = @shipment.shipping_method == shipping_method || @default_method == shipping_method
    if cost
      radio =  "<input type='radio' name='method_id' value='#{shipping_method.id}' #{"checked='true'" if checked} onclick='calculate_order_total(this);'/>" 
      radio += shipping_method.name
      radio += "&nbsp; (Cost: #{number_to_currency(cost)})"
    else
      radio =  "<input type='radio' name='method_id' disabled='true' onclick='calculate_order_total(this);'/>"
      radio += "<span class='disabled'>#{shipping_method.name}</span>" 
    end
    
    radio += "<script type=""text/javascript"">shipping_costs.set('#{shipping_method.id}',#{cost});</script>"
    
    radio
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree-0.5.0 vendor/extensions/shipping/app/helpers/shipments_helper.rb
spree-0.5.1 vendor/extensions/shipping/app/helpers/shipments_helper.rb