From c23c77394212326e8493a8332cad7cdbf931b523 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 26 Jun 2025 14:14:13 +1000 Subject: [PATCH 1/3] Simplify view code --- app/views/checkout/_details.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/checkout/_details.html.haml b/app/views/checkout/_details.html.haml index 73cb4435c2..2b64747303 100644 --- a/app/views/checkout/_details.html.haml +++ b/app/views/checkout/_details.html.haml @@ -91,7 +91,7 @@ "data-toggle-show": shipping_method.require_ship_address = shipping_method_form.label shipping_method.id, shipping_method.name, {for: "shipping_method_" + shipping_method.id.to_s } %em.fees= payment_or_shipping_price(shipping_method, @order) - - display_ship_address = display_ship_address || (ship_method_is_selected && shipping_method.require_ship_address) + - display_ship_address ||= ship_method_is_selected && shipping_method.require_ship_address .checkout-input{"data-shippingmethod-target": "shippingMethodDescription", "data-shippingmethodid": shipping_method.id , style: "display: #{ship_method_is_selected ? 'block' : 'none'}" } #distributor_address.panel - if shipping_method.description.present? From fcd68972404be7b4ecdcc3c91b53b2191c6515bb Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 26 Jun 2025 14:17:17 +1000 Subject: [PATCH 2/3] Prepare delivery details partial for conditional display --- .../checkout/_delivery_details.html.haml | 28 ++++++++++++++++++ app/views/checkout/_summary.html.haml | 29 +------------------ 2 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 app/views/checkout/_delivery_details.html.haml diff --git a/app/views/checkout/_delivery_details.html.haml b/app/views/checkout/_delivery_details.html.haml new file mode 100644 index 0000000000..2e8a75766b --- /dev/null +++ b/app/views/checkout/_delivery_details.html.haml @@ -0,0 +1,28 @@ +%div + .summary-subtitle + = t("checkout.step3.delivery_details.address") + %span + = @order.ship_address.firstname + = @order.ship_address.lastname + %div + = @order.ship_address.phone + %div + = @order.user.email if @order.user + %br + %div + = @order.ship_address.address1 + - unless @order.ship_address.address2.blank? + %div + = @order.ship_address.address2 + %div + = @order.ship_address.city + %div + = @order.ship_address.state + %div + = @order.ship_address.zipcode + %div + = @order.ship_address.country + - if @order.special_instructions.present? + %br + %em + = @order.special_instructions diff --git a/app/views/checkout/_summary.html.haml b/app/views/checkout/_summary.html.haml index 364a1f2570..6e4d98d2b0 100644 --- a/app/views/checkout/_summary.html.haml +++ b/app/views/checkout/_summary.html.haml @@ -11,34 +11,7 @@ = @order.shipping_method.name %em.fees= payment_or_shipping_price(@order.shipping_method, @order) .two-columns - %div - .summary-subtitle - = t("checkout.step3.delivery_details.address") - %span - = @order.ship_address.firstname - = @order.ship_address.lastname - %div - = @order.ship_address.phone - %div - = @order.user.email if @order.user - %br - %div - = @order.ship_address.address1 - - unless @order.ship_address.address2.blank? - %div - = @order.ship_address.address2 - %div - = @order.ship_address.city - %div - = @order.ship_address.state - %div - = @order.ship_address.zipcode - %div - = @order.ship_address.country - - if @order.special_instructions.present? - %br - %em - = @order.special_instructions + = render "delivery_details" - if @order.shipping_method.description.present? %div .summary-subtitle From 667b49b7f161a2fdffa3e98245d90df794094a7f Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 26 Jun 2025 14:19:39 +1000 Subject: [PATCH 3/3] Show hub address for pickup only when feature enabled --- app/views/checkout/_summary.html.haml | 2 +- lib/open_food_network/feature_toggle.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/checkout/_summary.html.haml b/app/views/checkout/_summary.html.haml index 6e4d98d2b0..a4cd24addc 100644 --- a/app/views/checkout/_summary.html.haml +++ b/app/views/checkout/_summary.html.haml @@ -11,7 +11,7 @@ = @order.shipping_method.name %em.fees= payment_or_shipping_price(@order.shipping_method, @order) .two-columns - = render "delivery_details" + = render "delivery_details" if @order.shipping_method.delivery? || feature?(:hub_address) - if @order.shipping_method.description.present? %div .summary-subtitle diff --git a/lib/open_food_network/feature_toggle.rb b/lib/open_food_network/feature_toggle.rb index 604f949084..a373917ea3 100644 --- a/lib/open_food_network/feature_toggle.rb +++ b/lib/open_food_network/feature_toggle.rb @@ -67,6 +67,9 @@ module OpenFoodNetwork "inventory" => <<~DESC, Enable the inventory. DESC + "hub_address" => <<~DESC, + Show the hub's address as shipping address on pickup orders. + DESC }.merge(conditional_features).freeze; # Features you would like to be enabled to start with.