Sha256: 2510476230d747e3862c281fa01477098e4a78b32624fcb6019cd470f53b5aaf

Contents?: true

Size: 759 Bytes

Versions: 4

Compression:

Stored size: 759 Bytes

Contents

Spree::Admin::VariantsController.class_eval do

  def edit
    @variant.volume_prices.build if @variant.volume_prices.empty?
    super
  end

  def volume_prices
    @product = @variant.product
    @variant.volume_prices.build if @variant.volume_prices.empty?
  end

  private

  # this loads the variant for the master variant volume price editing
  def load_resource_instance
    parent

    if new_actions.include?(params[:action].to_sym)
      build_resource
    elsif params[:id]
      Spree::Variant.find(params[:id])
    end
  end

  def location_after_save
    if @product.master.id == @variant.id && params[:variant].key?(:volume_prices_attributes)
      return volume_prices_admin_product_variant_url(@product, @variant)
    end
    super
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_volume_pricing-0.2.1 app/controllers/spree/admin/variants_controller_decorator.rb
solidus_volume_pricing-0.1.1 app/controllers/spree/admin/variants_controller_decorator.rb
solidus_volume_pricing-0.2.0 app/controllers/spree/admin/variants_controller_decorator.rb
solidus_volume_pricing-0.1.0 app/controllers/spree/admin/variants_controller_decorator.rb