Sha256: 8eb045e7842b2d64ed7fe7b529c248b1fb124e2481481531af745cceb90b44eb

Contents?: true

Size: 871 Bytes

Versions: 31

Compression:

Stored size: 871 Bytes

Contents

class FormLineItem
  include Forms::Models::Extension
  include Shop::Models::FormExtension
  
  # line_item:
  #   process: add|update|remove
  
  def create
    @result ||= {}
    find_or_create_current_order
    
    case process
    when 'add'
      @result[:add]    = @order.add(line_item_item_id,line_item_quantity,line_item_item_type)
    when 'modify'
      @result[:modify] = @order.modify(line_item_id,line_item_quantity)
    when 'remove'
      @result[:remove] = @order.remove(line_item_id)
    end
    
    @result
  end
  
  protected
  
  def process
    @config[:process]
  end
  
  def line_item
    @data[:line_item]
  end
  
  def line_item_id
    line_item[:id]
  end
  
  def line_item_item_id
    line_item[:item_id]
  end
  
  def line_item_item_type
    line_item[:item_type]
  end
  
  def line_item_quantity
    line_item[:quantity]
  end
  
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
radiant-shop-extension-0.92.2 app/models/form_line_item.rb
radiant-shop-extension-0.92.1 app/models/form_line_item.rb
radiant-shop-extension-0.92.0 app/models/form_line_item.rb
radiant-shop-extension-0.91.7 app/models/form_line_item.rb
radiant-shop-extension-0.91.4 app/models/form_line_item.rb
radiant-shop-extension-0.91.3 app/models/form_line_item.rb
radiant-shop-extension-0.91.2 app/models/form_line_item.rb
radiant-shop-extension-0.90.4 app/models/form_line_item.rb
radiant-shop-extension-0.90.2 app/models/form_line_item.rb
radiant-shop-extension-0.90.1 app/models/form_line_item.rb
radiant-shop-extension-0.90.0 app/models/form_line_item.rb