public
Description: A simple Spree shipping extension that calculates shipping using predefined amounts.
Homepage:
Clone URL: git://github.com/BDQ/spree-flexi-rate-shipping.git
spree-flexi-rate-shipping / flexi_rate_shipping_extension.rb
100644 40 lines (31 sloc) 1.057 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
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'
 
class FlexiRateShippingExtension < Spree::Extension
  version "0.7.1"
  description "Calculates shipping using predefined rates."
  url "http://github.com/BDQ/spree-flexi-rate-shipping/tree/master"
 
  define_routes do |map|
    map.namespace :admin do |admin|
      admin.resources :flexi_shipping_rates
    end
  end
 
 
  def activate
    ShippingCategory.class_eval do
      has_many :flexi_shipping_rates
    end
    
    Product.class_eval do
      belongs_to :shipping_category
    end
    
    Zone.class_eval do
      has_many :flexi_shipping_rates
    end
    
    Admin::ConfigurationsController.class_eval do
      before_filter :add_flexi_rate_links, :only => :index
      def add_flexi_rate_links
        @extension_links << {:link => admin_flexi_shipping_rates_path, :link_text => FlexiShippingRate.human_name(:count => 2), :description => t('flexi_shipping_rates_description')}
      end
    end
  end
  
  def deactivate
 
  end
end