mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Implemented simlified shop flow.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
include Spree::ProductsHelper
|
||||
include OrderCyclesHelper
|
||||
|
||||
class EnterprisesController < BaseController
|
||||
|
||||
@@ -29,8 +30,8 @@ class EnterprisesController < BaseController
|
||||
|
||||
@enterprise = Enterprise.find params[:id]
|
||||
|
||||
@searcher = Spree::Config.searcher_class.new(options)
|
||||
@products = @searcher.retrieve_products
|
||||
@products = []
|
||||
@products = current_order_cycle.products if current_order_cycle
|
||||
end
|
||||
|
||||
def shop
|
||||
@@ -39,6 +40,7 @@ class EnterprisesController < BaseController
|
||||
|
||||
if order.distributor and order.distributor != distributor
|
||||
order.empty!
|
||||
order.set_order_cycle! nil
|
||||
end
|
||||
|
||||
order.distributor = distributor
|
||||
|
||||
@@ -53,6 +53,7 @@ Spree::OrdersController.class_eval do
|
||||
redirect_to request.referer
|
||||
|
||||
elsif params[:commit] == 'Choose Order Cycle'
|
||||
@order.empty! # empty cart
|
||||
order_cycle = OrderCycle.active.find params[:order][:order_cycle_id]
|
||||
@order.set_order_cycle! order_cycle
|
||||
|
||||
@@ -61,6 +62,14 @@ Spree::OrdersController.class_eval do
|
||||
end
|
||||
end
|
||||
|
||||
def clear
|
||||
@order = current_order(true)
|
||||
current_distributor = @order.distributor
|
||||
@order.order_cycle = nil
|
||||
@order.set_order_cycle! nil
|
||||
redirect_to main_app.shop_enterprise_path(current_distributor.id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def populate_variant_attributes
|
||||
|
||||
@@ -6,7 +6,7 @@ Spree::ProductsController.class_eval do
|
||||
include OpenFoodWeb::SplitProductsByDistribution
|
||||
|
||||
respond_override :index => { :html => { :success => lambda {
|
||||
@products, @products_local, @products_remote = split_products_by_distribution @products, current_distributor, current_order_cycle
|
||||
@products = current_order_cycle.products if current_order_cycle
|
||||
} } }
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user