Sha256: 841a01718f534178eef84e050821e4263c696e974b5ae38af97bf4098939f1e3
Contents?: true
Size: 1.34 KB
Versions: 34
Compression:
Stored size: 1.34 KB
Contents
module Workarea module Admin class PricingOverridesController < Admin::ApplicationController required_permissions :orders before_action :find_override before_action :find_order def edit; end def update if @override.update(override_params) create_comment if params[:comment].present? && !request.xhr? update_pricing flash[:success] = t('workarea.admin.pricing_overrides.flash_messages.success') request.xhr? ? render(:edit) : redirect_to(storefront.cart_path) else flash[:error] = t('workarea.admin.pricing_overrides.flash_messages.error') render :edit end end private def find_override @override = Pricing::Override.find_or_create_by(id: params[:id]) end def find_order @order = Admin::OrderViewModel.new(Order.find(params[:id])) end def override_params PricingOverrideParams.new( params[:override].to_unsafe_h, current_admin ).to_h end def create_comment @order.model.comments.create!( body: params[:comment], author_id: current_user.id ) end def update_pricing shippings = Shipping.by_order(params[:id]) Pricing.perform(@order.model, shippings) end end end end
Version data entries
34 entries across 34 versions & 1 rubygems