狂欢货币转换器不适用于AED

时间:2016-01-26 09:27:52

标签: ruby-on-rails ruby-on-rails-4 rubygems spree

我在我的gem文件中包含了以下gem gem'spree_multi_currency',github:'spree / spree_multi_currency',branch:'2-3-stable'  在我的应用程序中,以下货币已经存在: 新元,美元,欧元,澳元,英镑,PHP,泰铢,马币 这些正在转换价格。但我的要求是添加AED货币,所以我在后端添加了SGD,USD,EUR,AUD,GBP,PHP,THB,MYR,AED enter image description here

现在,当我点击AED时,我现在自动在我的标题中获得此选项,它会给我以下错误

Started GET "/assets/world-globe.png" for 127.0.0.1 at 2016-01-26 10:26:08 +0100


Started POST "/currency/set" for 127.0.0.1 at 2016-01-26 10:26:11
+0100 Processing by Spree::CurrencyController#set as JSON   Parameters: {"currency"=>"AED"}   Spree::Country Load (1.1ms)  SELECT  "spree_countries".* FROM "spree_countries"  WHERE "spree_countries"."name" = 'N/A' LIMIT 1   Spree::User Load (1.2ms)  SELECT  "spree_users".* FROM "spree_users"  WHERE "spree_users"."id" = 1  ORDER BY "spree_users"."id" ASC LIMIT 1   Spree::Order Load (1.2ms) SELECT  "spree_orders".* FROM "spree_orders"  WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = 'USD' AND "spree_orders"."guest_token" = 'ZtR5IUlQUC40ueZBlo21Pg' AND "spree_orders"."user_id" = 1 LIMIT 1   Spree::Adjustment Load (1.4ms)  SELECT "spree_adjustments".* FROM "spree_adjustments"  WHERE "spree_adjustments"."adjustable_type" = 'Spree::Order' AND "spree_adjustments"."adjustable_id" IN (6084)  ORDER BY spree_adjustments.created_at ASC   Spree::Order Load (0.9ms)  SELECT "spree_orders".* FROM "spree_orders"  WHERE "spree_orders"."user_id" = $1 AND "spree_orders"."completed_at" IS NULL AND (id != 6084)  [["user_id", 1]]    (0.9ms)  BEGIN   Spree::Order Exists (1.7ms)  SELECT  1 AS one FROM "spree_orders"  WHERE ("spree_orders"."number" = 'R501407003' AND "spree_orders"."id" != 6084) LIMIT 1   Spree::LineItem Load (1.3ms)  SELECT "spree_line_items".* FROM "spree_line_items"  WHERE "spree_line_items"."order_id" = $1 AND (currency != 'AED')  ORDER BY created_at ASC  [["order_id", 6084]]   Spree::Variant Load (1.3ms)  SELECT  "spree_variants".* FROM "spree_variants"  WHERE "spree_variants"."id" = $1 LIMIT 1  [["id", 2]]   Spree::Price Load (1.3ms)  SELECT  "spree_prices".* FROM "spree_prices"  WHERE "spree_prices"."deleted_at" IS NULL AND "spree_prices"."variant_id" = $1 AND "spree_prices"."currency" = 'AED' ORDER BY "spree_prices"."id" ASC LIMIT 1  [["variant_id", 2]]   Spree::Product Load (1.3ms)  SELECT  "spree_products".* FROM "spree_products"  WHERE "spree_products"."id" = $1 LIMIT 1  [["id", 2]]   Spree::Product::Translation Load (1.3ms)  SELECT "spree_product_translations".* FROM "spree_product_translations"  WHERE "spree_product_translations"."spree_product_id" = $1  [["spree_product_id", 2]]    (1.5ms)  ROLLBACK Completed 500 Internal Server Error in 56ms

RuntimeError - no AED price found for 28 Day Ultimate Teatox (28 Day): () Users/TopFormInvestment/.rvm/gems/ruby-2.1.4@skinnymint/bundler/gems/spree-cfe7e96539b6/core/app/models/spree/order/currency_updater.rb:34:in `update_line_item_price!'    () Users/TopFormInvestment/.rvm/gems/ruby-2.1.4@skinnymint/bundler/gems/spree-cfe7e96539b6/core/app/models/spree/order/currency_updater.rb:18:in `block in update_line_item_currencies!'

请指导我如何解决此错误。因为我是狂热的新人

2 个答案:

答案 0 :(得分:2)

转到管理面板中的产品。在那里,您可以看到价格标签,点击标签,然后您自己更改价格。

enter image description here

答案 1 :(得分:-1)

您没有为变体28 Day Ultimate Teatox设置AED价格。在update_line_items_price中!它有一个局部变量价格,以新设定的货币返回变体价格。如果价格不存在,则会引发您获得的RuntimeError。

 def update_line_item_currencies!
    line_items.where('currency != ?', currency).each do |line_item|
      update_line_item_price!(line_item)
    end
  end

  # Returns the price object from given item
  def price_from_line_item(line_item)
    line_item.variant.prices.where(currency: currency).first
  end

  # Updates price from given line item
  def update_line_item_price!(line_item)
    price = price_from_line_item(line_item)

    if price
      line_item.update_attributes!(currency: price.currency, price: price.amount)
    else
      raise RuntimeError, "no #{currency} price found for #{line_item.product.name} (#{line_item.variant.sku})"
    end
  end