shivabhusal/storify

View on GitHub
app/views/carts/show.slim

Summary

Maintainability
Test Coverage
h1 Cart
- if @cart.items.present?
  h3 Cart Items
  - @cart.items.each do |item|
    .panel.panel-default
      .panel-body

        .col-md-2.margin10top
          = link_to item.product do
            = image_tag item.product.first_image, class: 'img-responsive'
        .col-md-10
          = link_to item.product do
            h4
              = item.product.name
              span.small
                - if item.product.author.present?
                  |  by 
                  = item.product.author
          hr
          = item.product.description
          .clearfix
          .row.margin10top
            .col-md-6
              table.table.table-striped
                tr
                  th Price
                  td = number_to_currency item.product.selling_price
          = link_to cart_path(id: item), method: :delete, class: 'btn btn-danger' do
            | Remove from Cart
  .row
    .col-md-6
      table.table.table-striped
        tr
          th Total Price
          td = number_to_currency @cart.items.total_amount
        tr
          th Total Tax
          td = number_to_currency @cart.items.total_tax_amount
        tr
          th Grand Total
          td = number_to_currency @cart.items.total_amount + @cart.items.total_tax_amount

  = link_to pre_checkout_cart_path, method: :post, class: 'btn btn-primary' do
    | Checkout
- else
  h3 No Item in the cart. Would you like to buy some?
  = link_to 'Shop', root_path