mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Inject only needed enterprises into cart and checkout
This commit is contained in:
@@ -5,6 +5,10 @@ module InjectionHelper
|
||||
inject_json_ams "enterprises", Enterprise.activated.includes(address: :state).all, Api::EnterpriseSerializer, enterprise_injection_data
|
||||
end
|
||||
|
||||
def inject_enterprise_and_relatives
|
||||
inject_json_ams "enterprises", current_distributor.relatives_including_self.activated.includes(address: :state).all, Api::EnterpriseSerializer, enterprise_injection_data
|
||||
end
|
||||
|
||||
def inject_shop_enterprises
|
||||
ocs = if current_order_cycle
|
||||
[current_order_cycle]
|
||||
|
||||
@@ -231,8 +231,8 @@ class Enterprise < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def relatives_and_oc_producers(order_cycles)
|
||||
enterprise_ids = Exchange.in_order_cycle(order_cycles).incoming.pluck :sender_id
|
||||
Enterprise.relatives_of_one_union_others(id, enterprise_ids)
|
||||
oc_producer_ids = Exchange.in_order_cycle(order_cycles).incoming.pluck :sender_id
|
||||
Enterprise.relatives_of_one_union_others(id, oc_producer_ids)
|
||||
end
|
||||
|
||||
def relatives_including_self
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
- content_for(:title) do
|
||||
= t :checkout_title
|
||||
|
||||
= inject_enterprises
|
||||
= inject_enterprise_and_relatives
|
||||
|
||||
.darkswarm.footer-pad
|
||||
- content_for :order_cycle_form do
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
- content_for(:title) do
|
||||
= t :orders_edit_title
|
||||
|
||||
= inject_enterprises
|
||||
= inject_enterprise_and_relatives
|
||||
|
||||
.darkswarm
|
||||
- content_for :order_cycle_form do
|
||||
|
||||
Reference in New Issue
Block a user