denny/ShinyCMS

View on GitHub
root/shop/basket/view_basket.tt

Summary

Maintainability
Test Coverage
[%-
    meta.wrapper = 'shop/wrapper.tt';
    meta.title   = 'Your Basket';
-%]

<h3>
    Your Basket
</h3>

[%- IF basket.basket_items %]

<form id="update_basket" action="basket/update" method="post">
    <p>
    [%- FOREACH basket_item IN basket.basket_items %]
        [%- attributes = basket_item.basket_item_attributes %]
        [%- IF basket_item.item.image %]
        <a href="[% c.uri_for( '/shop', 'item', basket_item.item.code ) %]"><img src="[% c.uri_for( '/static/cms-uploads/shop-images/thumbnails', basket_item.item.image ) %]" alt="Image of [% basket_item.item.name | html %]" title="Click to enlarge"></a>
        [%- END %]
        <a href="[% c.uri_for( '/shop', 'item', basket_item.item.code ) %]">[% basket_item.item.name | html %]</a>
        [%- IF attributes %]
        ([%- FOREACH attribute IN attributes -%]
        [%- attribute.name %]: [% attribute.value %][% ', ' UNLESS attribute == attributes.last -%]
        [%- END -%])
        [%- END %]
        [% currency %][% basket_item.unit_price | format('%.2f') %] each
        <input type="text" class="textnumber" name="quantity_[% basket_item.id %]" value="[% basket_item.quantity %]" size="2"> ([% currency %][% basket_item.total_price | format('%.2f') %])
    </p>
    [%- END %]
    <p>
        <input type="submit" name="update" value="Update basket">
    </p>
</form>

<p>
    Total: [% currency %][% basket.total_price | format('%.2f') %]
</p>
<p>
    <a href="[% c.uri_for( '/shop', 'checkout' ) %]">Go to checkout</a>
</p>
<p>
    <a href="[% c.uri_for( 'empty' ) %]">Empty basket</a>
</p>
[%- ELSE %]
<p>
    No items to display.
</p>
[%- END %]