mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Display subtotal for delivery fees
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
7
app/helpers/spree/orders_helper_decorator.rb
Normal file
7
app/helpers/spree/orders_helper_decorator.rb
Normal file
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user