Sha256: 270723189d15ea0afd3f45723c3a04dd6e256226a90983d6fcd3ef0eef63f5c9

Contents?: true

Size: 1.11 KB

Versions: 18

Compression:

Stored size: 1.11 KB

Contents

module Spree
  Product.class_eval do
    
    def incountry?(country)
      clist = Spree::Zoned::Product.where "spree_product_id = ? AND spree_country_id = ?", id, country
      clist == [] || clist[0].orderno >= 0
    end
    
    def delfrom(country)
      setorderno country, -1
    end
    
    def backtocountry(country)
      setorderno country, 0
    end

    def setprice(country, price)
      clist = Spree::Zoned::Product.where "spree_product_id = ? AND spree_country_id = ?", id, country
      if !clist || clist == []
        zp = Spree::Zoned::Product.new
        zp.spree_country_id = country
        zp.spree_product_id = id
        zp.orderno = 0
      else
        zp = clist[0]
      end
      zp.cprice = price
      zp.save
    end

  protected

    def setorderno(country, ono)
      clist = Spree::Zoned::Product.where "spree_product_id = ? AND spree_country_id = ?", id, country
      if clist == []
        zp = Spree::Zoned::Product.new
        zp.spree_country_id = country
        zp.spree_product_id = id
      else
        zp = clist[0]
      end
      zp.orderno = ono
      zp.save
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
spree_zoned-0.5.38 app/models/spree/product_decorator.rb
spree_zoned-0.5.37 app/models/spree/product_decorator.rb
spree_zoned-0.5.36 app/models/spree/product_decorator.rb
spree_zoned-0.5.35 app/models/spree/product_decorator.rb
spree_zoned-0.5.34 app/models/spree/product_decorator.rb
spree_zoned-0.5.33 app/models/spree/product_decorator.rb
spree_zoned-0.5.32 app/models/spree/product_decorator.rb
spree_zoned-0.5.31 app/models/spree/product_decorator.rb
spree_zoned-0.5.30 app/models/spree/product_decorator.rb
spree_zoned-0.5.29 app/models/spree/product_decorator.rb
spree_zoned-0.5.28 app/models/spree/product_decorator.rb
spree_zoned-0.5.27 app/models/spree/product_decorator.rb
spree_zoned-0.5.26 app/models/spree/product_decorator.rb
spree_zoned-0.5.25 app/models/spree/product_decorator.rb
spree_zoned-0.5.24 app/models/spree/product_decorator.rb
spree_zoned-0.5.23 app/models/spree/product_decorator.rb
spree_zoned-0.5.22 app/models/spree/product_decorator.rb
spree_zoned-0.5.21 app/models/spree/product_decorator.rb