Merge pull request #4799 from mkllnk/4771-back-to-shop-button

4771 Back to shop button
This commit is contained in:
Maikel
2020-03-17 19:51:02 +11:00
committed by GitHub
5 changed files with 28 additions and 5 deletions

View File

@@ -16,4 +16,8 @@ module SharedHelper
def admin_user?
spree_current_user.andand.has_spree_role? 'admin'
end
def current_shop_products_path
"#{main_app.enterprise_shop_path(current_distributor)}#/shop"
end
end

View File

@@ -22,7 +22,7 @@
- if @order.line_items.empty?
%div.row{"data-hook" => "empty_cart"}
%p= t(:your_cart_is_empty)
%p= link_to t(:continue_shopping), main_app.shop_path, :class => 'button continue'
%p= link_to t(:continue_shopping), current_shop_products_path, :class => 'button continue'
- else
%div{"data-hook" => "outside_cart_form"}

View File

@@ -1,6 +1,6 @@
.row.links{'data-hook' => "cart_buttons"}
.columns.large-8{"data-hook" => ""}
%a.button.large.secondary{href: main_app.shop_path}
%a.button.large.secondary{href: current_shop_products_path}
%i.ofn-i_008-caret-left
= t :orders_edit_continue
.columns.large-4.text-right

View File

@@ -1,12 +1,12 @@
.row
.columns.small-12.medium-3
- if current_order.andand.distributor == @order.distributor
- if current_order.line_items.present?
- if current_order.nil? || current_order.distributor.nil? || current_order.distributor == @order.distributor
- if current_order&.line_items.present?
= link_to main_app.cart_path, :class => "button expand" do
%i.ofn-i_008-caret-left
= t(:order_back_to_cart)
- else
= link_to main_app.shop_path, :class => "button expand" do
= link_to "#{main_app.enterprise_shop_path(@order.distributor)}#/shop", class: "button expand" do
%i.ofn-i_008-caret-left
= t(:order_back_to_store)
- else

View File

@@ -20,6 +20,25 @@ feature "full-page cart", js: true do
set_order order
end
describe "continue shopping" do
it "shows a button leading back to the shop" do
# Set up a shopfront message to test that we are not going to the
# home tab.
distributor.preferred_shopfront_message = "Test driven farming"
add_product_to_cart order, product_with_fee, quantity: 2
visit main_app.cart_path
expect(page).to have_link "Continue shopping"
click_link "Continue shopping"
expect(page).to have_no_link "Continue shopping"
expect(page).to have_button "Edit your cart"
expect(page).to have_no_content distributor.preferred_shopfront_message
end
end
describe "product description" do
it "does not link to the product page" do
add_product_to_cart order, product_with_fee, quantity: 2