Skip to content
Browse files

Continuation of work on upgrade to Spree 0.50

  • Loading branch information...
1 parent 72fc5d0 commit a4613d0518cd9256a7bfd6ece19e5c4b860ea2f2 @romul romul committed
View
19 app/controllers/google_checkout_notification_controller.rb
@@ -12,17 +12,14 @@ def create
if notification.is_a?(Google4R::Checkout::NewOrderNotification)
@order = Order.find_by_id(params[:new_order_notification][:shopping_cart][:merchant_private_data][:order_number].strip.to_i)
- unless @order.allow_pay?
+ unless @order.completed?
@order.update_attribute("user_id", current_user) if current_user
checkout_info = params[:new_order_notification]
- checkout_attrs = {
- :email => checkout_info[:email],
- :ip_address => request.env['REMOTE_ADDR']
- }
- @order.checkout.update_attributes(checkout_attrs)
-
+
order_attrs = {
+ :email => checkout_info[:email],
+ :ip_address => request.env['REMOTE_ADDR']
:adjustment_total => notification.order_adjustment.adjustment_total.cents.to_f / 100,
:buyer_id => notification.buyer_id,
:financial_order_state => notification.financial_order_state,
@@ -34,17 +31,17 @@ def create
new_billing_address =
create_spree_address_from_google_address(notification.buyer_billing_address)
- @order.checkout.update_attribute(:bill_address_id, new_billing_address.id)
+ @order.update_attribute(:bill_address_id, new_billing_address.id)
new_shipping_address =
create_spree_address_from_google_address(notification.buyer_shipping_address)
- @order.shipment.update_attribute(:address_id, new_shipping_address.id)
+ @order.update_attribute(:address_id, new_shipping_address.id)
ship_method = ShippingMethod.find_by_name(notification.order_adjustment.shipping.name)
- @order.shipment.update_attribute(:shipping_method, ship_method)
+ @order.update_attribute(:shipping_method, ship_method)
- @order.complete!
+ @order.next while @order.state != "complete"
end
render :text => 'proccess Google4R::Checkout::NewOrderNotification' and return
end
View
80 app/views/admin/orders/index.html.erb
@@ -1,80 +0,0 @@
-<% render :partial => 'admin/shared/order_sub_menu' %>
-
-<h1><%= t("listing_orders") %></h1>
-
-<table class="index">
- <thead>
- <tr>
- <th><%= order @search, :by => :created_at, :as => t("order_date") %></th>
- <th><%= order @search, :by => :number, :as => t("order_number") %></th>
- <th><%= order @search, :by => :state, :as => t("status") %></th>
- <th><%= order @search, :by => :checkout_email, :as => t("customer") %></th>
- <th><%= order @search, :by => :total, :as => t("total") %></th>
- <% if Billing::GoogleCheckout.current -%>
- <th colspan="3"><%= t(:google_checkout_status) %></th>
- <% end -%>
- </tr>
- </thead>
- <tbody>
- <% @orders.each do |order| %>
- <tr>
- <td><%= order.created_at.to_date%></td>
- <td><%= link_to order.number, object_url(order) %></td>
- <td><%= t(order.state.downcase) %></td>
- <td><%= order.email %></td>
- <td><%= number_to_currency order.total %></td>
- <%= render :partial => 'admin/shared/google_checkout_status', :locals =>{:order => order} if Billing::GoogleCheckout.current %>
- </tr>
- <% end %>
- </tbody>
-</table>
-<%= will_paginate(:previous_label => "&#171; #{t('previous')}", :next_label => "#{t('next')} &#187;") %>
-
-
-
-<% content_for :sidebar do %>
-<div class="box">
- <h3><%= t(:search) %></h3>
-
- <% form_for @search do |f| %>
- <label><%= t("date_range") %></label><br />
- <div class="yui-g date-range-filter">
- <div class="yui-u sub-field first">
- <%= f.unobtrusive_date_picker :created_at_after %><br />
- <label class="sub"><%= t("start") %></label>
- </div>
- <div class="yui-u sub-field">
- <%= f.unobtrusive_date_picker :created_at_before %><br />
- <label><%= t("stop") %></label>
- </div>
- </div>
-
- <p><label><%= t("status") %></label><br />
- <%= f.select :state_equals, Order.state_machines[:state].states.collect {|s| [t(s.name), s.value]}, {:include_blank => true} %></p>
-
- <p><label><%= t 'order_number' %></label><br />
- <%= f.text_field :number_contains, :size=>25 %></p>
-
- <p>
- <label><%= t 'email' %></label><br />
- <%= f.text_field :checkout_email_contains, :size=>25 %>
- </p>
- <p>
- <label><%= t 'first_name' %></label><br />
- <%= f.text_field :checkout_bill_address_firstname_contains, :size=>25 %>
- </p>
- <p>
- <label><%= t 'last_name' %></label><br />
- <%= f.text_field :checkout_bill_address_lastname_contains, :size=>25 %>
- </p>
- <p>
- <%= f.check_box :completed_at_not_null, {:style => "vertical-align:middle;"} %>
- <label>
- <%= t("show_only_complete_orders") %>
- </label>
- </p>
-
- <p><%= button t("search") %></p>
- <% end %>
-</div>
-<% end %>
View
2 app/views/admin/shared/_google_checkout_status.html.erb
@@ -1,4 +1,4 @@
-<% if order.google_order_number.present? %>
+<% if Billing::GoogleCheckout.current && order.google_order_number.present? %>
<td><% if order.allow_pay? && order.state!='paid' %>
<%= link_to(t("google_checkout.charge"), charge_google_order_admin_order_path(order)) %>
<% end %>
View
2 config/locales/en-US.yml → config/locales/en.yml
@@ -1,5 +1,5 @@
---
-en-US:
+en:
google_checkout:
cancel_order: "Cancel order"
charge: "Charge"
View
10 lib/spree_google_checkout_hooks.rb
@@ -1,3 +1,13 @@
class SpreeGoogleCheckoutHooks < Spree::ThemeSupport::HookListener
insert_after :outside_cart_form, 'shared/google_checkout_bar'
+
+ insert_after :admin_orders_index_headers do
+ %(
+ <% if Billing::GoogleCheckout.current -%>
+ <th colspan="3"><%= t(:google_checkout_status) %></th>
+ <% end -%>
+ )
+ end
+
+ insert_after :admin_orders_index_rows, 'admin/shared/google_checkout_status'
end

0 comments on commit a4613d0

Please sign in to comment.
Something went wrong with that request. Please try again.