There is an use case where this method that auto-selects the price depending on the customer role overwriting the price dict blocks the possibility of showing 2+ different prices to the template.
This could happen on B2B environments when for example in the system we have 2 pricelist that should be shown to the user:
Distribution Price
Retail Price
def _parse_response(response)
if @customer
role = @customer.role
end
role ||= @site.metafields['erp']['default_role']
response['hits']['hits'].each do |hit|
if hit["_source"].include?('price')
hit["_source"]['price'] = hit["_source"]['price'][role]
end
end
response
end
There is an use case where this method that auto-selects the price depending on the customer role overwriting the price dict blocks the possibility of showing 2+ different prices to the template. This could happen on B2B environments when for example in the system we have 2 pricelist that should be shown to the user:
https://github.com/shopinvader/locomotive-shopinvader/blob/v4.0.x/lib/shop_invader/services/elastic_service.rb#L102-L113
It would be possible to add a new metafield to control that behaviour as it is now is quite limiting.
My temporary solution has been avoid the use this parse and matching the 2 pricelist with the beginning of the role + _retail: