mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Summarise distribution fees in checkout after cart page
This commit is contained in:
13
app/helpers/checkout_helper.rb
Normal file
13
app/helpers/checkout_helper.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module CheckoutHelper
|
||||
def checkout_adjustments_for_summary(order)
|
||||
adjustments = order.adjustments.eligible
|
||||
|
||||
adjustments.reject! { |a| a.originator_type == 'Spree::TaxRate' && a.amount == 0 }
|
||||
|
||||
enterprise_fee_adjustments = adjustments.select { |a| a.originator_type == 'EnterpriseFee' }
|
||||
adjustments.reject! { |a| a.originator_type == 'EnterpriseFee' }
|
||||
adjustments << Spree::Adjustment.new(label: 'Distribution', amount: enterprise_fee_adjustments.sum(&:amount))
|
||||
|
||||
adjustments
|
||||
end
|
||||
end
|
||||
36
app/views/spree/checkout/_summary.html.erb
Normal file
36
app/views/spree/checkout/_summary.html.erb
Normal file
@@ -0,0 +1,36 @@
|
||||
<!-- Copied from spree. Modifications marked below. -->
|
||||
<h3><%= t(:order_summary) %></h3>
|
||||
|
||||
<table data-hook="order_summary">
|
||||
<tbody>
|
||||
<tr data-hook="item_total">
|
||||
<td><strong><%= t(:item_total) %>:</strong></td>
|
||||
<td><strong><%= order.display_item_total %></strong></td>
|
||||
</tr>
|
||||
<tbody id="summary-order-charges" data-hook>
|
||||
<!-- Begin modifications -->
|
||||
<% adjustments = checkout_adjustments_for_summary(order) %>
|
||||
<% adjustments.each do |adjustment| %>
|
||||
<tr>
|
||||
<td><%= adjustment.label %>: </td>
|
||||
<td><%= adjustment.display_amount.to_html %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- End modifications -->
|
||||
</tbody>
|
||||
<tr data-hook="order_total">
|
||||
<td><strong><%= t(:order_total) %>:</strong></td>
|
||||
<td><strong><span id='summary-order-total'><%= @order.display_total.to_html %></span></strong></td>
|
||||
</tr>
|
||||
<% if order.price_adjustment_totals.present? %>
|
||||
<tbody id="price-adjustments" data-hook="order_details_price_adjustments">
|
||||
<% @order.price_adjustment_totals.each do |label, total| %>
|
||||
<tr class="total">
|
||||
<td><strong><%= label %></strong></td>
|
||||
<td><strong><span><%= total %></span></strong></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -89,6 +89,13 @@ feature %q{
|
||||
['Product distribution by Edible garden for Garlic', '$2.00', '']]
|
||||
|
||||
page.should have_selector 'span.distribution-total', :text => '$3.00'
|
||||
|
||||
# When I check out
|
||||
click_link 'Checkout'
|
||||
|
||||
# Then I should see a summary of my distribution charges
|
||||
page.should have_selector 'tbody#summary-order-charges td', text: 'Distribution:'
|
||||
page.should have_selector 'tbody#summary-order-charges td', text: '$3.00'
|
||||
end
|
||||
|
||||
scenario "viewing delivery fees for order cycle distribution" do
|
||||
|
||||
Reference in New Issue
Block a user