mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Drop product.price from /api/ocs/:id/products
Its serializer it's only used by this endpoint and app/assets/javascripts/templates/shop_variant.html.haml doesn't rely on the response's product.price but the variant's price. Because our DB schema allows NULL on spree_prices.amount, a master variant without a price can cause the shopfront not to load products. This was the case in https://app.bugsnag.com/yaycode/openfoodnetwork-uk/errors/60adfcc31cf9740007f82fc9.
This commit is contained in:
@@ -3,7 +3,7 @@ require "open_food_network/scope_variant_to_hub"
|
||||
class Api::ProductSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :permalink, :meta_keywords
|
||||
attributes :group_buy, :notes, :description, :description_html
|
||||
attributes :properties_with_values, :price
|
||||
attributes :properties_with_values
|
||||
|
||||
has_many :variants, serializer: Api::VariantSerializer
|
||||
has_one :master, serializer: Api::VariantSerializer
|
||||
@@ -36,14 +36,6 @@ class Api::ProductSerializer < ActiveModel::Serializer
|
||||
options[:master_variants][object.id].andand.first
|
||||
end
|
||||
|
||||
def price
|
||||
if options[:enterprise_fee_calculator]
|
||||
object.master.price + options[:enterprise_fee_calculator].indexed_fees_for(object.master)
|
||||
else
|
||||
object.master.price_with_fees(options[:current_distributor], options[:current_order_cycle])
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sanitizer
|
||||
|
||||
Reference in New Issue
Block a user