Display subtotal for delivery fees

This commit is contained in:
Rohan Mitchell
2012-07-02 16:13:55 +10:00
parent 6f581fce43
commit aa027f6e29
4 changed files with 27 additions and 0 deletions

View File

@@ -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;
}
}
}

View 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

View File

@@ -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)

View File

@@ -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