Sha256: 80c6e04d5c1e9166a5a3e62c82b60c249fd52ec1af3d17fd558da9f3fe11b64a

Contents?: true

Size: 1.93 KB

Versions: 1

Compression:

Stored size: 1.93 KB

Contents

class ZonePricingExtension < Spree::Extension
  version "0.1.5"
  description "Spree Zone Pricing"
  url "https://github.com/henriquebf/spree-zone-pricing"

  # Please use zone_pricing/config/routes.rb instead for extension routes.

  # def self.require_gems(config)
  #   config.gem "gemname-goes-here", :version => '1.2.3'
  # end
  
  def activate

    # Add helper to retrieve the users country
    ApplicationHelper.send(:include, Spree::ZonePricing::GetCountry)
    # Add helper to retrieve the users country, used by a number of controllers
    Spree::BaseController.send(:include, Spree::ZonePricing::GetCountry)

    # Add additional associations to allow m:m relationship
    # between zones<->variants
    Zone.send(:include, Spree::ZonePricing::Zone)
    Variant.send(:include, Spree::ZonePricing::Variant)

    # Override add_variant method so that we can use zone pricing
    Order.send(:include, Spree::ZonePricing::Order)

    # Override price
    ProductsHelper.send(:include, Spree::ZonePricing::ProductsHelper)

    # Add action to countries controller to handle country selection
    CountriesController.send(:include, Spree::ZonePricing::CountriesController)
    # Add code to set the currently country in the order
    OrdersController.send(:include, Spree::ZonePricing::OrdersController)
    # Add code to save zone prices
    Admin::VariantsController.send(:include, Spree::ZonePricing::Admin::VariantsController)
    # Add code to check zone prices after address is saved during checkout, if ship
    # country not the same change prices in order
    CheckoutsController.send(:include, Spree::ZonePricing::CheckoutsController)

  end
end

class ZonePricingHooks < Spree::ThemeSupport::HookListener

  # Add zone pricing tab to products admin area
  insert_after :admin_product_tabs, :partial => "admin/shared/zp_product_tab"

  # Add zone pricing to variant edit form
  insert_after :admin_variant_edit_form, :partial => 'admin/shared/zone_prices'

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_zone_pricing-0.1.6 lib/spree_zone_pricing.rb