Class: Spree::PriceLists::Update

Inherits:
Workflow
  • Object
show all
Defined in:
app/workflows/spree/price_lists/update.rb

Overview

Updates a price list and applies the price overrides that ride with it. Product membership is not part of this payload — it lives on the uniform nested products surface, the same protocol categories, collections and catalogs use.

Instance Method Summary collapse

Methods inherited from Workflow

#call, define_argument_readers, #errors, #halt!, hooks, inherited, model_name, #read_attribute_for_validation, #reject!, workflow_key

Methods included from ServiceModule::Base

#call, prepended

Methods included from Workflow::ControlFlow

#failure

Instance Method Details

#perform(price_list:, attributes: {}) ⇒ Spree::ServiceModule::Result

Returns value is the price list.

Parameters:

  • price_list (Spree::PriceList)
  • attributes (Hash) (defaults to: {}) —

    may carry prices (each row optionally carrying min_quantity) and price_adjustment_tiers

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/workflows/spree/price_lists/update.rb', line 14

def perform(price_list:, attributes: {})
  super

  step :assign_attributes
  run_hooks :validate

  ApplicationRecord.transaction do
    step :save_price_list
    step :apply_prices
    run_hooks :after_update
  end

  success(price_list)
end