json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] do
  json.(variant, *variant_attributes)
  json.partial!("spree/api/variants/small", variant: variant)
  json.total_on_hand(variant.total_on_hand)
  json.variant_properties(variant.variant_properties) do |variant_property|
    json.(variant_property, *variant_property_attributes)
  end
  json.stock_items(variant.stock_items.accessible_by(current_ability)) do |stock_item|
    json.(stock_item, :id, :count_on_hand, :stock_location_id, :backorderable)
    json.available stock_item.available?
    json.stock_location_name(stock_item.stock_location.name)
  end
end

json.cache! [I18n.locale, Spree::StockLocation.accessible_by(current_ability), variant] do
  json.(variant, *variant_attributes)
  json.partial!("spree/api/variants/small", variant: variant)
  json.variant_properties(variant.variant_properties) do |variant_property|
    json.(variant_property, *variant_property_attributes)
  end
  json.stock_items(variant.stock_items.accessible_by(current_ability)) do |stock_item|
    json.(stock_item, :id, :count_on_hand, :stock_location_id, :backorderable)
    json.available stock_item.available?
    json.stock_location_name(stock_item.stock_location.name)
  end
end

Remove redundant total_on_hand declaration in api
Remove redundant total_on_hand declaration in api

This renders small.json.jbuilder as a partial which already has
total_on_hand.
