Sha256: 767b8cb6cb1f4071f973c99355af5349c92d91885f2dd710dd4c8aa175c6e399

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

class Plugins::Ecommerce::Admin::PricesController < Plugins::Ecommerce::AdminController
  before_action :set_shipping_method

  def index
  end

  def new
    @price = {}
    add_breadcrumb("#{t('plugins.ecommerce.new')}")
    render 'form'
  end

  def show
  end

  def edit
    @price = @prices[params[:id].to_sym] || {}
    add_breadcrumb("#{t('camaleon_cms.admin.button.edit')}")
    render 'form'
  end

  def create
    _id = Time.now.to_i.to_s
    data = params[:price]
    data[:id] = _id
    @prices[_id] = data
    @shipping_method.set_meta('prices', @prices)
    flash[:notice] = t('camaleon_cms.admin.post_type.message.created')
    redirect_to action: :index
  end

  def update
    _id = params[:id]
    @price = @prices[params[:id].to_sym] || {}
    @prices[_id] = @price.merge(params[:price])
    @shipping_method.set_meta('prices', @prices)
    flash[:notice] = t('camaleon_cms.admin.post_type.message.updated')
    redirect_to action: :index
  end

  def destroy
    @prices.delete(params[:id].to_sym)
    @shipping_method.set_meta('prices', @prices)
    flash[:notice] = t('camaleon_cms.admin.post_type.message.deleted')
    redirect_to action: :index
  end



  private
  def set_shipping_method
    @shipping_method = current_site.shipping_methods.find(params[:shipping_method_id])
    add_breadcrumb(t("plugins.ecommerce.shipping_methods"))
    add_breadcrumb(@shipping_method.name)
    add_breadcrumb(t("plugins.ecommerce.shipping_prices"), admin_plugins_ecommerce_shipping_method_prices_path(params[:shipping_method_id]))
    @prices = @shipping_method.get_meta("prices", {})
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
camaleon_ecommerce-2.0.4 app/controllers/plugins/ecommerce/admin/prices_controller.rb
camaleon_ecommerce-2.0.3 app/controllers/plugins/ecommerce/admin/prices_controller.rb
camaleon_ecommerce-2.0.2 app/controllers/plugins/ecommerce/admin/prices_controller.rb
camaleon_ecommerce-2.0.1 app/controllers/plugins/ecommerce/admin/prices_controller.rb
camaleon_ecommerce-2.0.0 app/controllers/plugins/ecommerce/admin/prices_controller.rb
camaleon_ecommerce-1.2.1 app/controllers/plugins/ecommerce/admin/prices_controller.rb