Implemented simlified shop flow.

This commit is contained in:
alexs333
2013-09-04 20:32:21 +10:00
parent 25b25b7681
commit 999bc2697a
19 changed files with 181 additions and 96 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

View File

@@ -0,0 +1,5 @@
$(document).ready ->
$("#order_order_cycle_id").change -> $("#order_cycle_select").submit()
$("#reset_order_cycle").click -> return false unless confirm "Performing this action will clear your cart."

View File

@@ -81,9 +81,8 @@ nav#filters {
#distribution-selection {
overflow: auto;
margin-bottom: 2em;
padding: 5px;
border: 2px solid #ccc;
@include border-radius(10px);
padding: 20px;
background-color: #f3f3f3;
.distributors {
float: left;
@@ -98,6 +97,14 @@ nav#filters {
}
.order-cycles {
select {
padding: 10px;
margin-top: 15px;
border: 2px solid white;
font-size: 1.5em;
}
float: left;
tr.local {
@@ -109,6 +116,13 @@ nav#filters {
}
}
.countdown-panel {
background: url("../countdown.png") no-repeat left;
min-height: 60px;
min-width: 70px;
padding-left: 77px;
}
/* Style the product source on the product details page in the
* same manner as the product properties table above it.
@@ -300,3 +314,12 @@ div.cleared {
#link-to-login {
padding: 10px;
}
.secondary {
color: #6A6A6A;
}
.hide {
display: none;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,20 @@
/
replace "footer"
%footer
%hr/
.row
.seven.columns.offset-by-three
%center
%h1 What is open food network?
%p
%i
Open food network is an online space in which people can connect with, trade and sell food directly with
Australian farmers. We aim to reconnect people with their food.
%hr/
.row
.five.columns.secondary.offset-by-seven.secondary
All rights reserved. &copy; 2013 Open Food Foundation

View File

@@ -2,6 +2,4 @@
.enterprise-description= @enterprise.long_description.andand.html_safe
%h3 Available Now
= render :template => 'spree/products/index'

View File

@@ -0,0 +1,26 @@
- if order_cycles_enabled?
#distribution-selection.row
- if current_order_cycle && current_order_cycle.exchanges.to_enterprises(current_distributor).outgoing.any?
.columns.six
%h1= "Your order will be ready on #{current_order_cycle.exchanges.to_enterprises(current_distributor).outgoing.first.pickup_time}"
%i
= link_to 'Change Pick-up Date', spree.clear_orders_path, :id => 'reset_order_cycle'
(This will reset your cart)
%p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
.columns.five
.row
%strong ORDERS CLOSE
.countdown-panel
%h1= distance_of_time_in_words_to_now(current_order_cycle.orders_close_at)
- else
.columns.two= image_tag 'pickup.png'
.columns.six
%h2 When do you want your order?
%p No products are displayed until you select a date.
= form_for current_order(true), :html => {:id => 'order_cycle_select'} do |f|
= f.hidden_field :distributor_id, :value => @enterprise.id
.order-cycles
= f.select :order_cycle_id, @order_cycles.select{ |oc| oc.distributors.include? current_distributor }.collect {|o| [ distance_of_time_in_words_to_now(o.orders_close_at), o.id ] }, {include_blank: 'Pick-up date'}
= hidden_field_tag :commit, 'Choose Order Cycle'

View File

@@ -13,7 +13,8 @@
- else
= render 'add_to_cart_quantity_fields', product: @product
%div.cleared
-#temporary hiding the options to choose order cycles and distributors
%div.cleared.hide
%br
- available_distributors = available_distributors_for(order, @product)
- available_order_cycles = available_order_cycles_for(order, @product)