jdutil/spree_bootstrap

View on GitHub
app/views/spree/checkout/_summary.html.erb

Summary

Maintainability
Test Coverage
<h3><%= Spree.t(:order_summary) %></h3>

<table data-hook="order_summary">
  <tbody>
    <tr data-hook="item_total">
      <td><strong><%= Spree.t(:item_total) %>:</strong></td>
      <td><strong><%= order.display_item_total.to_html %></strong></td>
    </tr>

    <% if order.line_item_adjustments.exists? %>
      <tbody data-hook="order_details_promotion_adjustments">
        <% order.line_item_adjustments.promotion.eligible.group_by(&:label).each do |label, adjustments| %>
          <tr class="total">
            <td><%= label %></td>
            <td><%= Spree::Money.new(adjustments.sum(&:amount)).to_html %></td>
          </tr>
        <% end %>
      </tbody>
    <% end %>

    <tbody data-hook="order_details_tax_adjustments">
      <% order.all_adjustments.tax.eligible.group_by(&:label).each do |label, adjustments| %>
        <tr class="total">
          <td><%= label %></td>
          <td><%= Spree::Money.new(adjustments.sum(&:amount)).to_html %></td>
        </tr>
      <% end %>
    </tbody>

    <% if order.checkout_steps.include?("delivery") && order.shipments.any? %>
      <tr data-hook="shipping_total">
        <td><%= Spree.t(:shipping_total) %></td>
        <td><%= Spree::Money.new(order.shipments.to_a.sum(&:cost)).to_html %></td>
      </tr>

      <% if order.shipment_adjustments.exists? %>
        <tbody data-hook="order_details_shipment_promotion_adjustments">
          <% order.shipment_adjustments.promotion.eligible.group_by(&:label).each do |label, adjustments| %>
            <tr class="total">
              <td><%= label %></td>
              <td><%= Spree::Money.new(adjustments.sum(&:amount)).to_html %></td>
            </tr>
          <% end %>
        </tbody>
      <% end %>
    <% end %>

    <% if order.adjustments.eligible.exists? %>
      <tbody id="summary-order-charges" data-hook>
        <% order.adjustments.eligible.each do |adjustment| %>
        <% next if (adjustment.source_type == 'Spree::TaxRate') and (adjustment.amount == 0) %>
          <tr class="total">
            <td><%= adjustment.label %>: </td>
            <td><%= adjustment.display_amount.to_html %></td>
          </tr>
        <% end %>
      </tbody>
    <% end %>

    <tr data-hook="order_total">
      <td><strong><%= Spree.t(:order_total) %>:</strong></td>
      <td><strong><span id='summary-order-total'><%= order.display_total.to_html %></span></strong></td>
    </tr>
  </tbody>
</table>