diff --git a/app/helpers/spree/paypal_helper.rb b/app/helpers/spree/paypal_helper.rb new file mode 100644 index 0000000..c4d9feb --- /dev/null +++ b/app/helpers/spree/paypal_helper.rb @@ -0,0 +1,7 @@ +module Spree + module PaypalHelper + def pay_with_paypal? + @order.state == 'payment' and @order.payable_via_paypal? + end + end +end diff --git a/app/overrides/paypal_form.rb b/app/overrides/paypal_form.rb new file mode 100644 index 0000000..f2d2c2d --- /dev/null +++ b/app/overrides/paypal_form.rb @@ -0,0 +1,4 @@ +Deface::Override.new(:virtual_path => "spree/checkout/edit", + :surround_contents => "[data-hook='checkout_form_wrapper']", + :text => "<% if pay_with_paypal? -%><%= render :partial => 'spree/checkout/paypal_checkout' %><% else -%><%= render_original %><% end -%>", + :name => "paypal_form") diff --git a/app/views/spree/checkout/edit.html.erb b/app/views/spree/checkout/edit.html.erb deleted file mode 100755 index 44f9931..0000000 --- a/app/views/spree/checkout/edit.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<% content_for :head do %> - <%= javascript_include_tag '/states' %> -<% end %> -
-

<%= t("checkout")%>

- <%= checkout_progress %> -
- <%= render "spree/shared/error_messages", :target => @order %> - <%= hook :checkout_summary_box do %> -
- <%= render 'summary', :order => @order %> -
- <% end %> - - - <% if(@order.state == "payment") %> - <%= render('spree/checkout/paypal_checkout') if @order.payable_via_paypal? %> - <% else %> - <%= form_for @order, :url => update_checkout_path(@order.state), :html => { :id => "checkout_form_#{@order.state}" } do |form| %> - <%= render @order.state, :form => form %> - - <% end %> - <% end %> -
- -
- -
diff --git a/lib/spree_paypal_website_standard/engine.rb b/lib/spree_paypal_website_standard/engine.rb index 3686f46..75665ef 100644 --- a/lib/spree_paypal_website_standard/engine.rb +++ b/lib/spree_paypal_website_standard/engine.rb @@ -24,8 +24,12 @@ class Engine < Rails::Engine def self.activate Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c| - Rails.configuration.cache_classes ? require(c) : load(c) - end + Rails.configuration.cache_classes ? require(c) : load(c) + end + + Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c| + Rails.configuration.cache_classes ? require(c) : load(c) + end # add new events and states to the FSM =begin