mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add message about previous orders on checkout page
The message appears if the user ordered before within the same order cycle and the shop allows to change previous orders.
This commit is contained in:
committed by
Rob Harrington
parent
3bce2eb7b5
commit
f3f6714472
@@ -89,7 +89,11 @@ module EnterprisesHelper
|
||||
distance_of_time_in_words(Time.zone.now, enterprise.shop_trial_start_date + Spree::Config[:shop_trial_length_days].days)
|
||||
end
|
||||
|
||||
def show_bought_items?
|
||||
def order_changes_allowed?
|
||||
current_order.andand.distributor.andand.allow_order_changes?
|
||||
end
|
||||
|
||||
def show_bought_items?
|
||||
order_changes_allowed? && current_order.finalised_line_items.present?
|
||||
end
|
||||
end
|
||||
|
||||
2
app/views/checkout/_already_ordered.html.haml
Normal file
2
app/views/checkout/_already_ordered.html.haml
Normal file
@@ -0,0 +1,2 @@
|
||||
%p.alert-box.info
|
||||
= t '.message_html', cart: link_to(t('.cart'), cart_path)
|
||||
@@ -11,6 +11,7 @@
|
||||
= render "checkout/billing", f: f
|
||||
= render "checkout/shipping", f: f
|
||||
= render "checkout/payment", f: f
|
||||
= render "checkout/already_ordered", f: f if show_bought_items?
|
||||
%p
|
||||
%button.button.primary{type: :submit}
|
||||
= t :checkout_send
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
= "{{ Cart.dirty ? '#{t(:cart_updating)}' : (Cart.empty() ? '#{t(:cart_empty)}' : '#{t(:cart_edit)}' ) }}"
|
||||
%a.button.primary.tiny{href: checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
|
||||
= t '.checkout'
|
||||
- if show_bought_items?
|
||||
- if order_changes_allowed?
|
||||
%h5{"ng-if" => "Cart.line_items_finalised.length", style: 'margin-top: 1em'}
|
||||
= t '.already_ordered_products'
|
||||
%table
|
||||
|
||||
@@ -550,6 +550,15 @@ en:
|
||||
invoice_style2?: Use the alternative invoice model that includes total tax breakdown per rate and tax rate info per item (not yet suitable for countries displaying prices excluding tax)
|
||||
enable_receipt_printing?: Show options for printing receipts using thermal printers in order dropdown?
|
||||
|
||||
# Frontend views
|
||||
#
|
||||
# These keys are referenced relatively like `t('.message')` in
|
||||
# app/views/checkout/_already_ordered.html.haml.
|
||||
#
|
||||
checkout:
|
||||
already_ordered:
|
||||
cart: "cart"
|
||||
message_html: "You have an order for this order cycle already. Check the %{cart} to see the items you ordered before. You can also cancel items as long as the order cycle is open."
|
||||
home:
|
||||
hubs:
|
||||
show_closed_shops: "Show closed shops"
|
||||
|
||||
@@ -113,6 +113,24 @@ feature "As a consumer I want to check out my cart", js: true, retry: 3 do
|
||||
user.reload.bill_address.address1.should eq '123 Your Head'
|
||||
user.reload.ship_address.address1.should eq '123 Your Head'
|
||||
end
|
||||
|
||||
it "it doesn't tell about previous orders" do
|
||||
expect(page).to_not have_content("You have an order for this order cycle already.")
|
||||
end
|
||||
|
||||
context "with previous orders" do
|
||||
let!(:prev_order) { create(:completed_order_with_totals, order_cycle: order_cycle, distributor: distributor, user: order.user) }
|
||||
|
||||
before do
|
||||
order.distributor.allow_order_changes = true
|
||||
order.distributor.save
|
||||
end
|
||||
|
||||
it "informs about previous orders" do
|
||||
visit checkout_path
|
||||
expect(page).to have_content("You have an order for this order cycle already.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "on the checkout page" do
|
||||
|
||||
Reference in New Issue
Block a user