Hello. i'm trying add my custom price filter

#/lib/venum.rb
module Venum
   def price_filter_venum
     v = Spree::Price.arel_table
     conds = [ [ Spree.t(:under_price, price: format_price(1000)) , v[:
amount].lteq(1000)],
               [ "#{format_price(1000)} - #{format_price(1500)}" , v[:
amount].in(1000..1500)],
               [ "#{format_price(1500)} - #{format_price(1999)}" , v[:
amount].in(1500..1999)],
               [ "#{format_price(2000)} - #{format_price(3000)}" , v[:
amount].in(2000..3000)],
               [ Spree.t(:or_over_price, price: format_price(3000)) , v[:
amount].gteq(3000)]]
     {
         name: Spree.t(:price_range),
         scope: :price_range_any,
         conds: Hash[*conds.flatten],
         labels: conds.map { |k,v| [k, k] }
     }
   end
end


#/config/initializers/spree.rb
require 'venum'
Spree::ProductFilters.include(Venum)

i got error:

/Users/danil/Sites/venum-shop/config/initializers/spree.rb:20:in `<top
(required)>': uninitialized constant Spree::ProductFilters (NameError)


*How should i include this method right?*

later i want change template using deface (to use price_filter_venum
instead price_filter)

Search Discussions

  • Ryan Bigg at Sep 1, 2013 at 11:15 pm
    Hi Danil,

    You're seeing this error because the class is now called
    Spree::Core:ProductFilters, rather than Spree::ProductFilters.


    On Fri, Aug 30, 2013 at 9:17 PM, Danil Zvyagintsev
    wrote:
    Hello. i'm trying add my custom price filter

    #/lib/venum.rb
    module Venum
    def price_filter_venum
    v = Spree::Price.arel_table
    conds = [ [ Spree.t(:under_price, price: format_price(1000)) , v[:
    amount].lteq(1000)],
    [ "#{format_price(1000)} - #{format_price(1500)}" , v
    [:amount].in(1000..1500)],
    [ "#{format_price(1500)} - #{format_price(1999)}" , v
    [:amount].in(1500..1999)],
    [ "#{format_price(2000)} - #{format_price(3000)}" , v
    [:amount].in(2000..3000)],
    [ Spree.t(:or_over_price, price: format_price(3000)) , v[:
    amount].gteq(3000)]]
    {
    name: Spree.t(:price_range),
    scope: :price_range_any,
    conds: Hash[*conds.flatten],
    labels: conds.map { |k,v| [k, k] }
    }
    end
    end


    #/config/initializers/spree.rb
    require 'venum'
    Spree::ProductFilters.include(Venum)

    i got error:

    /Users/danil/Sites/venum-shop/config/initializers/spree.rb:20:in `<top
    (required)>': uninitialized constant Spree::ProductFilters (NameError)


    *How should i include this method right?*

    later i want change template using deface (to use price_filter_venum
    instead price_filter)


    --

    Ryan Bigg
    Community Manager
    Spree Commerce, Inc.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedAug 30, '13 at 1:34p
activeSep 1, '13 at 11:15p
posts2
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

Danil Zvyagintsev: 1 post Ryan Bigg: 1 post

People

Translate

site design / logo © 2022 Grokbase