mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-10 03:30:22 +00:00
Merge pull request #9009 from jibees/9007-already-opened-cart
SplitCheckout: add already opened cart message on summary step when distributor allow order changes
This commit is contained in:
@@ -14,6 +14,7 @@ class SplitCheckoutController < ::BaseController
|
||||
helper 'terms_and_conditions'
|
||||
helper 'checkout'
|
||||
helper 'spree/orders'
|
||||
helper EnterprisesHelper
|
||||
helper OrderHelper
|
||||
|
||||
before_action :set_checkout_redirect
|
||||
|
||||
3
app/views/split_checkout/_already_ordered.html.haml
Normal file
3
app/views/split_checkout/_already_ordered.html.haml
Normal file
@@ -0,0 +1,3 @@
|
||||
.already-ordered
|
||||
.panel.medium-6
|
||||
= t("split_checkout.already_ordered.message_html", cart: link_to(t('split_checkout.already_ordered.cart'), "#{main_app.cart_path}#bought-products"))
|
||||
@@ -1,4 +1,5 @@
|
||||
%checkout.row#checkout
|
||||
.small-12.medium-12.columns
|
||||
= render partial: "split_checkout/tabs"
|
||||
= render partial: "split_checkout/already_ordered" if show_bought_items? && checkout_step?(:summary)
|
||||
= render partial: "split_checkout/form"
|
||||
|
||||
@@ -58,6 +58,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
.already-ordered {
|
||||
.panel {
|
||||
margin-top: 3rem;
|
||||
background-color: $grey-250;
|
||||
border: 1px solid $tiny-blue;
|
||||
color: $grey-700;
|
||||
|
||||
&.medium-6, &.medium-10 {
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.already-ordered .panel, #distributor_address.panel {
|
||||
font-size: 0.875rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.checkout-step {
|
||||
margin-top: 3rem;
|
||||
|
||||
@@ -119,9 +138,6 @@
|
||||
}
|
||||
|
||||
#distributor_address.panel {
|
||||
font-size: 0.875rem;
|
||||
padding: 1rem;
|
||||
|
||||
span {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
@@ -1751,6 +1751,9 @@ en:
|
||||
your_details_without_number: Your details
|
||||
payment_method_without_number: Payment method
|
||||
order_summary_without_number: Order summary
|
||||
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."
|
||||
step1:
|
||||
your_details:
|
||||
title: Your details
|
||||
|
||||
@@ -674,7 +674,9 @@ describe "As a consumer, I want to checkout my order", js: true do
|
||||
end
|
||||
|
||||
context "summary step" do
|
||||
let(:order) { create(:order_ready_for_confirmation, distributor: distributor) }
|
||||
let(:order) {
|
||||
create(:order_ready_for_confirmation, distributor: distributor)
|
||||
}
|
||||
|
||||
describe "completing the checkout" do
|
||||
it "keeps the distributor selected for the current user after completion" do
|
||||
@@ -837,5 +839,32 @@ describe "As a consumer, I want to checkout my order", js: true do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with previous open orders" do
|
||||
let(:order) {
|
||||
create(:order_ready_for_confirmation, distributor: distributor,
|
||||
order_cycle: order_cycle, user_id: user.id)
|
||||
}
|
||||
let!(:prev_order) {
|
||||
create(:completed_order_with_totals,
|
||||
order_cycle: order_cycle, distributor: distributor, user_id: order.user_id)
|
||||
}
|
||||
|
||||
it "informs about previous orders if distributor allow order changes" do
|
||||
order.distributor.allow_order_changes = true
|
||||
order.distributor.save
|
||||
visit checkout_step_path(:summary)
|
||||
|
||||
expect(page).to have_content("You have an order for this order cycle already.")
|
||||
end
|
||||
|
||||
it "don't display any message if distributor don't allow order changes" do
|
||||
order.distributor.allow_order_changes = false
|
||||
order.distributor.save
|
||||
visit checkout_step_path(:summary)
|
||||
|
||||
expect(page).to_not have_content("You have an order for this order cycle already.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user