Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 70 lines (65 sloc) 2.79 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'

class ActiveShippingExtension < Spree::Extension
  version "0.9.0"
  description "Describe your extension here"
  url "http://yourwebsite.com/active_shipping"

  def activate
    [
      Calculator::Ups::Ground,
      Calculator::Ups::NextDayAir,
      Calculator::Ups::NextDayAirEarlyAm,
      Calculator::Ups::NextDayAirSaver,
      Calculator::Ups::Saver,
      Calculator::Ups::SecondDayAir,
      Calculator::Ups::ThreeDaySelect,
      Calculator::Ups::WorldwideExpedited,
      Calculator::Fedex::ExpressSaver,
      Calculator::Fedex::FirstOvernight,
      Calculator::Fedex::Ground,
      Calculator::Fedex::GroundHomeDelivery,
      Calculator::Fedex::InternationalEconomy,
      Calculator::Fedex::InternationalEconomyFreight,
      Calculator::Fedex::InternationalFirst,
      Calculator::Fedex::InternationalGround,
      Calculator::Fedex::InternationalPriority,
      Calculator::Fedex::InternationalPriorityFreight,
      Calculator::Fedex::InternationalPrioritySaturdayDelivery,
      Calculator::Fedex::OneDayFreight,
      Calculator::Fedex::OneDayFreightSaturdayDelivery,
      Calculator::Fedex::PriorityOvernight,
      Calculator::Fedex::PriorityOvernightSaturdayDelivery,
      Calculator::Fedex::StandardOvernight,
      Calculator::Fedex::ThreeDayFreight,
      Calculator::Fedex::ThreeDayFreightSaturdayDelivery,
      Calculator::Fedex::StandardOvernight,
      Calculator::Fedex::ThreeDayFreight,
      Calculator::Fedex::ThreeDayFreightSaturdayDelivery,
      Calculator::Fedex::TwoDay,
      Calculator::Fedex::TwoDayFreight,
      Calculator::Fedex::TwoDayFreightSaturdayDelivery,
      Calculator::Fedex::TwoDaySaturdayDelivery,
      Calculator::Usps::MediaMail,
      Calculator::Usps::ExpressMail,
      Calculator::Usps::ExpressMailInternational,
      Calculator::Usps::PriorityMail,
      Calculator::Usps::PriorityMailInternational,
      Calculator::Usps::PriorityMailSmallFlatRateBox,
      Calculator::Usps::PriorityMailRegularMediumFlatRateBoxes,
      Calculator::Usps::PriorityMailLargeFlatRateBox
    ].each(&:register)

    # handle shipping errors gracefully on admin ui
    Admin::ShipmentsController.class_eval do
      rescue_from Spree::ShippingError, :with => :handle_shipping_error

      private
        def handle_shipping_error(e)
          load_object
          flash.now[:error] = e.message
          render :action => "edit"
        end
    end

    #Only required until following active_shipping commit is merged (add negotiated rates).
    #http://github.com/BDQ/active_shipping/commit/2f2560d53aa7264383e5a35deb7264db60eb405a
    ActiveMerchant::Shipping::UPS.send(:include, Spree::ActiveShipping::UpsOverride)
  end
end
Something went wrong with that request. Please try again.