Refactoring digital shipping calculation and display
* removed the deface override that modified the checkout/_delivery partial * created custom digital delivery calculator * removed digital_shipping_method from Spree::Order. Moved logic to available_shipping_methods monkey patch The main goal was to eliminate the shipping method detection logic from the _delivery partial. This was a bit of a hack all along and didn't really present the correct information to the underlying order logic (i.e. rate_hash.blank? would return true when there was no shipping options available). This should be more future proof and make overriding another aspect of the delivery process easier.
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
Deface::Override.new(:virtual_path => "spree/checkout/_delivery",
|
||||
:name => "modify_shipping_options_display",
|
||||
:replace_contents => "#shipping_method #methods p.radios",
|
||||
:original => %q{
|
||||
<% @order.rate_hash.each do |shipping_method| %>
|
||||
<label>
|
||||
<%= radio_button(:order, :shipping_method_id, shipping_method[:id]) %>
|
||||
<% if Spree::Config[:shipment_inc_vat] %>
|
||||
<%= shipping_method[:name] %> <%= format_price (1 + Spree::TaxRate.default) * shipping_method[:cost] %>
|
||||
<% else %>
|
||||
<%= shipping_method[:name] %> <%= number_to_currency shipping_method[:cost] %>
|
||||
<% end %>
|
||||
</label>
|
||||
<% end %>
|
||||
},
|
||||
:text => %q{
|
||||
<% if @order.digital? && @order.digital_shipping_method.present? %>
|
||||
<label>
|
||||
<%= radio_button :order, :shipping_method_id, @order.digital_shipping_method[:id] %>
|
||||
<%== t 'digital_shipping', :email => @order.email %> (<%= number_to_currency @order.digital_shipping_method[:cost] %>)
|
||||
</label>
|
||||
<% else %>
|
||||
<% filtered_rate_hash = @order.rate_hash.select { |m| !(@order.digital_shipping_method && m[:id] == @order.digital_shipping_method[:id]) } %>
|
||||
<% if filtered_rate_hash.count > 0 %>
|
||||
<% filtered_rate_hash.each do |shipping_method| %>
|
||||
<label>
|
||||
<%= radio_button(:order, :shipping_method_id, shipping_method[:id]) %>
|
||||
<% if Spree::Config[:shipment_inc_vat] %>
|
||||
<%= shipping_method[:name] %> <%= format_price (1 + Spree::TaxRate.default) * shipping_method[:cost] %>
|
||||
<% else %>
|
||||
<%= shipping_method[:name] %> <%= number_to_currency shipping_method[:cost] %>
|
||||
<% end %>
|
||||
</label>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= t :no_shipping_methods %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
})
|
||||
Reference in New Issue
Block a user