diff --git a/app/assets/stylesheets/store/openfoodweb.css.scss b/app/assets/stylesheets/store/openfoodweb.css.scss index 98d912cfbe..a5ae8ea8cb 100644 --- a/app/assets/stylesheets/store/openfoodweb.css.scss +++ b/app/assets/stylesheets/store/openfoodweb.css.scss @@ -174,4 +174,15 @@ ul.product-listing { } } } + + .subtotal { + width: 100%; + text-align: right; + text-transform: uppercase; + margin-top: 15px; + + span.order-total { + @extend span.price; + } + } } diff --git a/app/helpers/spree/orders_helper_decorator.rb b/app/helpers/spree/orders_helper_decorator.rb new file mode 100644 index 0000000000..cb735cb570 --- /dev/null +++ b/app/helpers/spree/orders_helper_decorator.rb @@ -0,0 +1,7 @@ +module Spree + module OrdersHelper + def order_delivery_fee_subtotal(order) + number_to_currency order.line_items.map { |li| li.itemwise_shipping_cost }.sum + end + end +end diff --git a/app/views/spree/orders/_distributor_fees.html.haml b/app/views/spree/orders/_distributor_fees.html.haml index 580a7cba33..256ea38073 100644 --- a/app/views/spree/orders/_distributor_fees.html.haml +++ b/app/views/spree/orders/_distributor_fees.html.haml @@ -15,3 +15,9 @@ %h4= link_to line_item.product.name, product_path(line_item.product) %td.item-shipping-method= line_item.shipping_method.name %td.item-shipping-cost= number_to_currency line_item.itemwise_shipping_cost + + .subtotal{'data-hook' => 'delivery_fees_subtotal'} + %h5 + = t(:subtotal) + \: + %span.order-total= order_delivery_fee_subtotal(@order) diff --git a/spec/requests/consumer/checkout_spec.rb b/spec/requests/consumer/checkout_spec.rb index 077452f74b..29d5fb1583 100644 --- a/spec/requests/consumer/checkout_spec.rb +++ b/spec/requests/consumer/checkout_spec.rb @@ -56,11 +56,14 @@ feature %q{ # Item | Shipping Method | Delivery Fee # Garlic | Shipping Method Two | $2.00 # Fuji apples | Shipping Method One | $1.00 + # + # Subtotal: $3.00 table = page.find 'table#delivery' rows = table.all('tr') rows[0].all('th').map { |cell| cell.text.strip }.should == ['Item', 'Shipping Method', 'Delivery Fee'] rows[1].all('td').map { |cell| cell.text.strip }.should == ['Fuji apples', 'Shipping Method One', '$1.00'] rows[2].all('td').map { |cell| cell.text.strip }.should == ['Garlic', 'Shipping Method Two', '$2.00'] + page.should have_selector '#delivery-fees span.order-total', :text => '$3.00' end