Sha256: 75fb000f2b1ad6238d2467bb606a545dda953015d8b67ad198ee1cb4b3f53587
Contents?: true
Size: 1016 Bytes
Versions: 23
Compression:
Stored size: 1016 Bytes
Contents
module Spree module Admin class PricesController < ResourceController belongs_to 'spree/product', find_by: :slug def create params.require(:vp).permit! params[:vp].each do |variant_id, prices| next unless variant_id variant = parent.variants_including_master.find(variant_id) next unless variant supported_currencies_for_all_stores.each do |currency| price = variant.price_in(currency.iso_code) price.price = (prices[currency.iso_code]['price'].blank? ? nil : prices[currency.iso_code]['price']) price.compare_at_price = (prices[currency.iso_code]['compare_at_price'].blank? ? nil : prices[currency.iso_code]['compare_at_price']) price.save! if price.new_record? && price.price || !price.new_record? && price.changed? end end flash[:success] = Spree.t('notice_messages.prices_saved') redirect_to spree.admin_product_path(parent) end end end end
Version data entries
23 entries across 23 versions & 1 rubygems