簡體   English   中英

價格表在Spree中的清單產品所在的位置?

[英]Where in Spree is the prices table joined to the products for lists?

我修改了Spree,以便產品/變體可以具有多個價格。 這意味着產品具有one_time價格, recurring_price價格和consumption_price價格。 為此,我在Price模型中添加了一個price_type字段。 現在我對列表有疑問。 該產品被列出3次,因為在某個地方價格內部連接在一起,從而導致列表中3個不同價格類型的3個條目。 我在哪里修復此問題,這意味着內部僅對列表進行price_type = one_time (或除非另行指定,否則通常如此)?

我發現了一些問題,到目前為止,它對我仍然有效:

Spree::Product.class_eval do

  class << self
    alias_method :orig_available, :available

    def available(available_on = nil, _currency = nil)
      orig_available(available_on, _currency).where("#{Spree::Price.quoted_table_name}.price_type = ?", Spree::Price.price_types[:one_time])
    end

  end
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM