我在修改 spree 中的功能时遇到问题。该函数称为copy_price
原始版本是这样的:
def copy_price
if variant
self.price = variant.price if price.nil?
self.currency = variant.currency if currency.nil?
end
end
如果我理解正确,它将仅在价格为空时更新 line_item 的单价,我认为它不应该在订单页面内(在订单完成后)。我注意到即使在订单完成后,如果在管理部分内更改主价格,订单也会发生变化。
所以我认为应该归咎于 copy_price 功能,但每次我尝试修改它时都没有改变。例如
def copy_price
@price_run = true
self.price = 30.00
end
def get_price_run
if @price_run == true
return "true"
else
return "false"
end
end
并在我的视图中调用 get_price_run 以打印出价格运行是否实际运行。它一直输出假。有谁知道为什么会这样。