diff --git a/app/controllers/split_checkout_controller.rb b/app/controllers/split_checkout_controller.rb index 6e69f85bf2..27fdb901ab 100644 --- a/app/controllers/split_checkout_controller.rb +++ b/app/controllers/split_checkout_controller.rb @@ -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 diff --git a/app/views/split_checkout/_already_ordered.html.haml b/app/views/split_checkout/_already_ordered.html.haml new file mode 100644 index 0000000000..a5361811cf --- /dev/null +++ b/app/views/split_checkout/_already_ordered.html.haml @@ -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")) diff --git a/app/views/split_checkout/_checkout.html.haml b/app/views/split_checkout/_checkout.html.haml index f26c8c4ca9..aa72ebc2f1 100644 --- a/app/views/split_checkout/_checkout.html.haml +++ b/app/views/split_checkout/_checkout.html.haml @@ -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" diff --git a/app/webpacker/css/darkswarm/split-checkout.scss b/app/webpacker/css/darkswarm/split-checkout.scss index a336878767..dde049254f 100644 --- a/app/webpacker/css/darkswarm/split-checkout.scss +++ b/app/webpacker/css/darkswarm/split-checkout.scss @@ -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; } diff --git a/config/locales/en.yml b/config/locales/en.yml index dd80b52668..d973822da5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index d12ce9f18e..9d6f14421c 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -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