Sha256: 763051a21239d5c9d4f45020ef29ab24532f6fd9f128ba8346036c96c91a2649

Contents?: true

Size: 1.04 KB

Versions: 28

Compression:

Stored size: 1.04 KB

Contents

class StockItem
  constructor: (options = {}) ->
    @id = options.id
    @variantId = options.variantId
    @backorderable = options.backorderable
    @countOnHand = options.countOnHand
    @stockLocationId = options.stockLocationId

  save: (successHandler, errorHandler) ->
    Spree.ajax
      url: Spree.routes.stock_items_api(@stockLocationId)
      type: "POST"
      data:
        stock_item:
          variant_id: @variantId
          backorderable: @backorderable
          count_on_hand: @countOnHand
      success: (stockItem) ->
        successHandler(stockItem)
      error: (errorData) ->
        errorHandler(errorData)

  update: (successHandler, errorHandler) ->
    Spree.ajax
      url: "#{Spree.routes.stock_items_api(@stockLocationId)}/#{@id}"
      type: "PUT"
      data:
        stock_item:
          backorderable: @backorderable
          count_on_hand: @countOnHand
          force: true
      success: (stockItem) ->
        successHandler(stockItem)
      error: (errorData) ->
        errorHandler(errorData)

Spree.StockItem = StockItem

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
solidus_backend-1.2.3 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.1.4 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.0.7 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.0.6 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.2.2 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.2.1 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.1.3 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.0.5 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.2.0 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.2.0.rc2 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.0.4 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.1.2 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.2.0.rc1 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.2.0.beta1 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.0.3 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.1.1 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.1.0 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.1.0.pre2 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.1.0.pre1 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee
solidus_backend-1.1.0.beta1 app/assets/javascripts/spree/backend/stock_management/stock_item.coffee