From 648f412cebdaaf619ed8e8dc6ee6079b8ec0ce94 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Tue, 1 May 2012 11:35:43 -0400 Subject: [PATCH 1/6] Resolving internationalization conflict with spree_essentials --- app/views/spree/admin/digitals/_form.html.erb | 2 +- config/locales/en.yml | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/spree/admin/digitals/_form.html.erb b/app/views/spree/admin/digitals/_form.html.erb index 09662da..e017113 100644 --- a/app/views/spree/admin/digitals/_form.html.erb +++ b/app/views/spree/admin/digitals/_form.html.erb @@ -25,7 +25,7 @@ <%= hidden_field_tag 'digital[variant_id]', variant.id %> - <%= button t("upload") %> + <%= button t('spree_digital.upload') %> <% end %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index 4fc0c04..17ed8bc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,12 +1,11 @@ en: digital_versions: Digital Versions - current_file: Current File new_file: New File - upload: Upload delete_file: Delete this file broken_file: Warning! this file is broken delete_file_cofirmation: Are you sure you want to delete the file %{filename}? - digital_shipping: Delivery per email to %{email} - \ No newline at end of file + + spree_digital: + upload: Upload \ No newline at end of file From 596006e8e18bcfb83bbbadad864d8fba1726f789 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Tue, 1 May 2012 11:45:53 -0400 Subject: [PATCH 2/6] Updating copied templates from spree --- .../spree/checkout/_delivery_digital.html.erb | 11 +++++--- .../checkout/_delivery_original.html.erb | 26 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/views/spree/checkout/_delivery_digital.html.erb b/app/views/spree/checkout/_delivery_digital.html.erb index 8a48847..29cd068 100644 --- a/app/views/spree/checkout/_delivery_digital.html.erb +++ b/app/views/spree/checkout/_delivery_digital.html.erb @@ -1,9 +1,12 @@
<%= t("shipping_method") %> - - <%= radio_button :order, :shipping_method_id, @order.digital_shipping_method[:id] %> - <%==t 'digital_shipping', :email => current_user.email %> (<%= number_to_currency @order.digital_shipping_method[:cost] %>) - +
+
+

+ <%= radio_button :order, :shipping_method_id, @order.digital_shipping_method[:id] %> + <%==t 'digital_shipping', :email => current_user.email %> (<%= number_to_currency @order.digital_shipping_method[:cost] %>) +

+
diff --git a/app/views/spree/checkout/_delivery_original.html.erb b/app/views/spree/checkout/_delivery_original.html.erb index df15e09..3277af9 100644 --- a/app/views/spree/checkout/_delivery_original.html.erb +++ b/app/views/spree/checkout/_delivery_original.html.erb @@ -4,29 +4,35 @@ Feel free to update the code below according to the original if needed! %> -
- <%= t("shipping_method") %> -
+
+ <%= t(:shipping_method) %> +

<% @order.rate_hash.each do |shipping_method| %> - <% next if @order.digital_shipping_method && shipping_method[:id] == @order.digital_shipping_method[:id] %> + <% next if @order.digital_shipping_method && shipping_method[:id] == @order.digital_shipping_method[:id] %>
+ <% end %> + <% end %>

<% if Spree::Config[:shipping_instructions] && @order.rate_hash.present? %> -

- <%= form.label :special_instructions, t("shipping_instructions") %>
+

+ <%= form.label :special_instructions, t(:shipping_instructions) %>
<%= form.text_area :special_instructions, :cols => 40, :rows => 7 %>

<% end %>
-
- "/> -
\ No newline at end of file +
+ +
+ <%= submit_tag t(:save_and_continue), :class => 'continue button primary' %> +
From e737739f5152f2c4ed7977526cae9b54b3aa00ec Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Wed, 2 May 2012 16:00:00 -0400 Subject: [PATCH 3/6] Removing explicit overrides load. This is done automatically --- lib/spree_digital/engine.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/spree_digital/engine.rb b/lib/spree_digital/engine.rb index faf02a0..d4cd82e 100644 --- a/lib/spree_digital/engine.rb +++ b/lib/spree_digital/engine.rb @@ -17,10 +17,6 @@ module SpreeDigital Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c| Rails.application.config.cache_classes ? require(c) : load(c) end - - Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c| - Rails.application.config.cache_classes ? require(c) : load(c) - end end config.to_prepare &method(:activate).to_proc From c780e6f7564ab02abe00e0aee1b0507d5357a6d8 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Wed, 2 May 2012 16:05:12 -0400 Subject: [PATCH 4/6] Replacing _delivery partial overrides with deface --- .../modify_shipping_options_display.rb | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app/overrides/modify_shipping_options_display.rb diff --git a/app/overrides/modify_shipping_options_display.rb b/app/overrides/modify_shipping_options_display.rb new file mode 100644 index 0000000..148f6ec --- /dev/null +++ b/app/overrides/modify_shipping_options_display.rb @@ -0,0 +1,35 @@ +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| %> + + <% end %> + }, + :text => %q{ +<% if @order.digital? && @order.digital_shipping_method.present? %> + +<% else %> +<% @order.rate_hash.each do |shipping_method| %> +<% next if @order.digital_shipping_method && shipping_method[:id] == @order.digital_shipping_method[:id] %> + +<% end %> +<% end %> +}) \ No newline at end of file From 65de5ee7d7966c31a59a2b51aa05b1245d998186 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Wed, 2 May 2012 16:09:19 -0400 Subject: [PATCH 5/6] Deleting old delivery partials --- app/views/spree/checkout/_delivery.html.erb | 5 --- .../spree/checkout/_delivery_digital.html.erb | 15 -------- .../checkout/_delivery_original.html.erb | 38 ------------------- 3 files changed, 58 deletions(-) delete mode 100644 app/views/spree/checkout/_delivery.html.erb delete mode 100644 app/views/spree/checkout/_delivery_digital.html.erb delete mode 100644 app/views/spree/checkout/_delivery_original.html.erb diff --git a/app/views/spree/checkout/_delivery.html.erb b/app/views/spree/checkout/_delivery.html.erb deleted file mode 100644 index 2a6c89d..0000000 --- a/app/views/spree/checkout/_delivery.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%# - This is basically a switch that will render the appropriate "delivery choice" partial. - When there are no physical items at all, there should be no different shipping methods to choose. -%> -<%= render @order.digital? && @order.digital_shipping_method.present? ? 'delivery_digital' : 'delivery_original' %> \ No newline at end of file diff --git a/app/views/spree/checkout/_delivery_digital.html.erb b/app/views/spree/checkout/_delivery_digital.html.erb deleted file mode 100644 index 29cd068..0000000 --- a/app/views/spree/checkout/_delivery_digital.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -
- <%= t("shipping_method") %> -
-
-

- <%= radio_button :order, :shipping_method_id, @order.digital_shipping_method[:id] %> - <%==t 'digital_shipping', :email => current_user.email %> (<%= number_to_currency @order.digital_shipping_method[:cost] %>) -

-
-
-
- -
- "/> -
diff --git a/app/views/spree/checkout/_delivery_original.html.erb b/app/views/spree/checkout/_delivery_original.html.erb deleted file mode 100644 index 3277af9..0000000 --- a/app/views/spree/checkout/_delivery_original.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -<%# - NOTE: The code below is an exact duplication of `spree_core/views/checkout/_delivery.html.erb“ - We overwrote the original so we retain access to it by cloning it here. - Feel free to update the code below according to the original if needed! -%> - -
- <%= t(:shipping_method) %> -
-
-

- <% @order.rate_hash.each do |shipping_method| %> - <% next if @order.digital_shipping_method && shipping_method[:id] == @order.digital_shipping_method[:id] %> - - <% end %> -

-
- <% if Spree::Config[:shipping_instructions] && @order.rate_hash.present? %> -

- <%= form.label :special_instructions, t(:shipping_instructions) %>
- <%= form.text_area :special_instructions, :cols => 40, :rows => 7 %> -

- <% end %> -
-
- -
- -
- <%= submit_tag t(:save_and_continue), :class => 'continue button primary' %> -
From c5f0c79a03741a004418ffe80ea623eb069dbeb1 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Thu, 3 May 2012 10:59:32 -0400 Subject: [PATCH 6/6] Present message to user when no shipping methods are available --- app/overrides/modify_shipping_options_display.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/overrides/modify_shipping_options_display.rb b/app/overrides/modify_shipping_options_display.rb index 148f6ec..e05104a 100644 --- a/app/overrides/modify_shipping_options_display.rb +++ b/app/overrides/modify_shipping_options_display.rb @@ -20,7 +20,9 @@ Deface::Override.new(:virtual_path => "spree/checkout/_delivery", <%== t 'digital_shipping', :email => @order.email %> (<%= number_to_currency @order.digital_shipping_method[:cost] %>) <% else %> -<% @order.rate_hash.each do |shipping_method| %> +<% filtered_rate_hash = @order.rate_hash.select { |m| !(@order.digital_shipping_method && shipping_method[:id] == @order.digital_shipping_method[:id]) } %> +<% if filtered_rate_hash.count > 0 %> +<% filtered_rate_hash.each do |shipping_method| %> <% next if @order.digital_shipping_method && shipping_method[:id] == @order.digital_shipping_method[:id] %> <% end %> +<% else %> +<%= t :no_shipping_methods %> +<% end %> <% end %> }) \ No newline at end of file