Sha256: d232272221396f79c334f0a399d8f713066f8e0e42853d665c07a9c5b2646bfb

Contents?: true

Size: 977 Bytes

Versions: 15

Compression:

Stored size: 977 Bytes

Contents

require_dependency 'spree/shipping_calculator'
# For #to_d method on Ruby 1.8
require 'bigdecimal/util'

module Spree
  module Calculator::Shipping
    class PriceSack < ShippingCalculator
      preference :minimal_amount, :decimal, :default => 0
      preference :normal_amount, :decimal, :default => 0
      preference :discount_amount, :decimal, :default => 0
      preference :currency, :string, :default => Spree::Config[:currency]

      attr_accessible :preferred_minimal_amount,
                      :preferred_normal_amount,
                      :preferred_discount_amount,
                      :preferred_currency

      def self.description
        Spree.t(:shipping_price_sack)
      end

      def compute_package(package)
        content_items = package.contents
        if total(content_items) < self.preferred_minimal_amount
          self.preferred_normal_amount
        else
          self.preferred_discount_amount
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spree_core-2.0.13 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.12 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.11 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.10 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.9 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.8 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.7 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.6 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.5 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.4 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.3 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.2 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.1 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.0 app/models/spree/calculator/shipping/price_sack.rb
spree_core-2.0.0.rc1 app/models/spree/calculator/shipping/price_sack.rb