Created
February 21, 2013 20:47
-
-
Save geermc4/5008086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/models/spree/calculator/fedex_mx/base.rb b/app/models/spree/calculator/fedex_mx/base.rb | |
new file mode 100644 | |
index 0000000..cae023a | |
--- /dev/null | |
+++ b/app/models/spree/calculator/fedex_mx/base.rb | |
@@ -0,0 +1,22 @@ | |
+require_dependency 'spree/calculator' | |
+ | |
+module Spree | |
+ class Calculator < ActiveRecord::Base | |
+ module FedexMx | |
+ class Base < Spree::Calculator::ActiveShipping::Base | |
+ def carrier | |
+ carrier_details = { | |
+ :key => Spree::ActiveShipping::Config[:fedex_mx_key], | |
+ :password => Spree::ActiveShipping::Config[:fedex_mx_password], | |
+ :account => Spree::ActiveShipping::Config[:fedex_mx_account], | |
+ :login => Spree::ActiveShipping::Config[:fedex_mx_login], | |
+ :test => Spree::ActiveShipping::Config[:test_mode] | |
+ } | |
+ | |
+ ActiveMerchant::Shipping::FedEx.new(carrier_details) | |
+ end | |
+ end | |
+ end | |
+ end | |
+end | |
+ | |
diff --git a/app/models/spree/calculator/fedex_mx/international_priority.rb b/app/models/spree/calculator/fedex_mx/international_priority.rb | |
new file mode 100644 | |
index 0000000..2ba6b40 | |
--- /dev/null | |
+++ b/app/models/spree/calculator/fedex_mx/international_priority.rb | |
@@ -0,0 +1,18 @@ | |
+require_dependency 'spree/calculator' | |
+ | |
+module Spree | |
+ class Calculator < ActiveRecord::Base | |
+ module FedexMx | |
+ class InternationalPriority < Calculator::FedexMx::Base | |
+ def self.description | |
+ I18n.t("fedex.intl_priority") | |
+ end | |
+ | |
+ def self.display | |
+ I18n.t("fedex_mx.intl_priority") | |
+ end | |
+ end | |
+ end | |
+ end | |
+end | |
+ | |
diff --git a/app/overrides/change_shipping_method_display.rb b/app/overrides/change_shipping_method_display.rb | |
new file mode 100644 | |
index 0000000..23f3b47 | |
--- /dev/null | |
+++ b/app/overrides/change_shipping_method_display.rb | |
@@ -0,0 +1,4 @@ | |
+Deface::Override.new(:virtual_path => "spree/admin/shared/_calculator_fields", | |
+ :name => "change_shipping_method_display", | |
+ :replace => "code[erb-loud]:contains('f.select(:calculator_type')", | |
+ :text => "<%= f.select(:calculator_type, @calculators.map { |c| [(c.display || c.description), c.name] }, {}, {:id => 'calc_type', :class => 'select2 fullwidth'}) %>") | |
diff --git a/config/application.rb b/config/application.rb | |
index 6264004..d681d0a 100644 | |
--- a/config/application.rb | |
+++ b/config/application.rb | |
@@ -70,5 +70,9 @@ module Store | |
config.assets.version = '1.0' | |
config.assets.paths << Rails.root.join('vendor/assets/fonts') | |
+ | |
+ initializer "spree.register.calculators" do |app| | |
+ app.config.spree.calculators.shipping_methods << Spree::Calculator::FedexMx::Base.descendants | |
+ end | |
end | |
end | |
diff --git a/config/initializers/fedex_mx.rb b/config/initializers/fedex_mx.rb | |
new file mode 100644 | |
index 0000000..d071bf6 | |
--- /dev/null | |
+++ b/config/initializers/fedex_mx.rb | |
@@ -0,0 +1,6 @@ | |
+Spree::ActiveShippingConfiguration.class_eval do | |
+ preference :fedex_mx_login, :string, :default => "meter_no" | |
+ preference :fedex_mx_password, :string, :default => "special_sha1_looking_thing_sent_via_email" | |
+ preference :fedex_mx_account, :string, :default => "account_no" | |
+ preference :fedex_mx_key, :string, :default => "authorization_key" | |
+end | |
diff --git a/config/initializers/shipping.rb b/config/initializers/shipping.rb | |
index 9fecdc3..045df3c 100644 | |
--- a/config/initializers/shipping.rb | |
+++ b/config/initializers/shipping.rb | |
@@ -59,6 +59,12 @@ else | |
Spree::ActiveShipping::Config[:fedex_password] = "x1" | |
Spree::ActiveShipping::Config[:fedex_account] = "y1" | |
Spree::ActiveShipping::Config[:fedex_login] = "z1" | |
+ | |
+ Spree::ActiveShipping::Config[:fedex_mx_key] = "w2" | |
+ Spree::ActiveShipping::Config[:fedex_mx_password] = "x2" | |
+ Spree::ActiveShipping::Config[:fedex_mx_account] = "y2" | |
+ Spree::ActiveShipping::Config[:fedex_mx_login] = "z2" | |
+ | |
Spree::ActiveShipping::Config[:test_mode] = true | |
end | |
diff --git a/config/locales/en.yml b/config/locales/en.yml | |
index 67cec9c..9123a9c 100644 | |
--- a/config/locales/en.yml | |
+++ b/config/locales/en.yml | |
@@ -43,3 +43,5 @@ en: | |
tax_id: "Tax ID" | |
edit_my_info: "Edit my Info" | |
company_info: "Company Info" | |
+ fedex_mx: | |
+ intl_priority: "Mx - FedEx International Priority" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment