Sha256: 1fa187f53c27d6957ec7e156b27d4957fe3cbd10ab6c0579a2f7d894d43089b4

Contents?: true

Size: 576 Bytes

Versions: 2

Compression:

Stored size: 576 Bytes

Contents

class Plugins::Ecommerce::ShippingMethod < CamaleonCms::TermTaxonomy
  default_scope { where(taxonomy: :ecommerce_shipping_method) }
  belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id

  scope :actives, -> {where(status: '1')}

  def get_price_from_weight(weight = 0)
    price_total = 0
    prices = get_meta("prices")
    if prices.present?
      prices.each do |key, value|
        price_total = value[:price] if value[:min_weight].to_f <= weight.to_f && value[:max_weight].to_f >= weight.to_f
      end
    end
    price_total.to_f
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
camaleon_ecommerce-1.2.1 app/models/plugins/ecommerce/shipping_method.rb
camaleon_ecommerce-1.2 app/models/plugins/ecommerce/shipping_method.rb