return totalPrice;
}
+ @Override
+ public Float calculateTotalPrice () {
+ // Init total price
+ Float totalPrice = 0.0f;
+
+ // Iterate over all items
+ for (final AddableBasketItem item : this.allItems()) {
+ // Is the item a product?
+ if (item.isProductType()) {
+ // Calculate single price and add it
+ totalPrice += this.calculateItemPrice(item);
+ }
+ }
+
+ // Return final sum
+ return totalPrice;
+ }
+
@Override
public Long getAmount () {
return this.amount;
this.currentItem = currentItem;
}
+ @Override
+ public Long getItemAmount (final Product product) {
+ // Initial value is zero
+ Long itemAmount = 0L;
+
+ // Iterate over all
+ for (final AddableBasketItem item : this.allItems()) {
+ // Is this product instance and same?
+ if ((item.isProductType()) && (item.getProduct().equals(product))) {
+ // Found it
+ itemAmount = item.getAmount();
+ break;
+ }
+ }
+
+ // Return it
+ return itemAmount;
+ }
+
@Override
public AddableBasketItem getLast () {
// Deligate to basket instance
<h:column>
<f:facet name="header">Einzelpreis:</f:facet>
- <ui:fragment rendered="#{item.isProductType()}">
- <h:outputText class="price" value="#{item.product.price}">
- <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
- </h:outputText>
- </ui:fragment>
+ <div class="item_price">
+ <ui:fragment rendered="#{item.isProductType()}">
+ <h:outputText class="price" value="#{item.product.price}">
+ <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+ </h:outputText>
+ </ui:fragment>
+ </div>
</h:column>
<h:column>
<h:column>
<f:facet name="header">Zwischensumme:</f:facet>
- <h:outputText id="item_price" value="#{basketController.calculateItemPrice(item)}" rendered="#{item.isProductType()}">
- <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
- </h:outputText>
+ <div class="item_total_price">
+ <h:outputText class="price" id="item_price" value="#{basketController.calculateItemPrice(item)}" rendered="#{item.isProductType()}">
+ <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+ </h:outputText>
+ </div>
</h:column>
</h:dataTable>
+ <div class="totals_container">
+ Gesamtsumme:
+ <h:outputText class="price" id="total_sum" value="#{basketController.calculateTotalPrice()}">
+ <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+ </h:outputText>
+ </div>
+
<h:outputText class="empty_basket" value="Es befinden sich derzeit keine Artikel im Warenkorb." rendered="#{basketController.isEmpty()}" />
</ui:define>
</div>
<div class="item_content">
- <div class="item_actions">
- <ui:fragment rendered="#{!basketController.isProductAdded(product)}">
- <h:form acceptcharset="utf-8" id="add_item">
- <h:commandButton class="submit" id="add" value="Hinzufügen" action="#{basketController.addItem(product)}" title="#{msg.BUTTON_TITLE_ADD_ITEM_TO_BASKET}" />
-
- <h:inputText class="input" id="amount" size="3" maxlength="20" value="#{basketController.amount}" title="#{msg.INPUT_TITLE_ENTER_ITEM_AMOUNT}">
- <!--
- If the customer wants to order more, he need to call in.
- //-->
- <f:validator for="amount" validatorId="ItemAmountValidator" />
- </h:inputText>
- </h:form>
- </ui:fragment>
-
- <ui:fragment rendered="#{basketController.isProductAdded(product)}">
- <div class="item_amount">
- #{basketController.amount}
- </div>
-
- <div class="item_basket_link">
- <h:link outcome="basket" title="Zum Warenkorb" value="Im Warenkorb ändern" />
- </div>
-
- <div class="clear"></div>
- </ui:fragment>
- </div>
+ <div class="table_left">
+ <div class="item_actions">
+ <ui:fragment rendered="#{!basketController.isProductAdded(product)}">
+ <h:form acceptcharset="utf-8" id="add_item">
+ <h:commandButton class="submit" id="add" value="Hinzufügen" action="#{basketController.addItem(product)}" title="#{msg.BUTTON_TITLE_ADD_ITEM_TO_BASKET}" />
+
+ <h:inputText class="input" id="amount" size="3" maxlength="20" value="#{basketController.amount}" title="#{msg.INPUT_TITLE_ENTER_ITEM_AMOUNT}">
+ <!--
+ If the customer wants to order more, he need to call in.
+ //-->
+ <f:validator for="amount" validatorId="ItemAmountValidator" />
+ </h:inputText>
+ </h:form>
+ </ui:fragment>
+
+ <ui:fragment rendered="#{basketController.isProductAdded(product)}">
+ <div class="item_amount">
+ Anzahl:
+ #{basketController.getItemAmount(product)}
+ </div>
+
+ <div class="item_basket_link">
+ <h:link outcome="basket" title="Zum Warenkorb" value="Im Warenkorb ändern" />
+ </div>
- <div class="item_price">
- Einzelpreis:
- <h:outputText class="price" value="#{product.price}">
- <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
- </h:outputText>
+ <div class="clear"></div>
+ </ui:fragment>
+ </div>
</div>
- <div class="item_total_price">
- Zwischensumme:
- <h:outputText class="price" value="Nicht bestellt." rendered="#{!basketController.isProductAdded(product)}" />
- <h:outputText class="price" value="#{basketController.calculateCurrentItemPrice()}" rendered="#{basketController.isProductAdded(product)}">
- <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
- </h:outputText>
+ <div class="table_right">
+ <div class="item_price">
+ Einzelpreis:
+ <h:outputText class="price" value="#{product.price}">
+ <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+ </h:outputText>
+ </div>
+
+ <div class="item_total_price">
+ Zwischensumme:
+ <h:outputText class="price" value="Nicht bestellt." rendered="#{!basketController.isProductAdded(product)}" />
+ <h:outputText class="price" value="#{basketController.calculateCurrentItemPrice()}" rendered="#{basketController.isProductAdded(product)}">
+ <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+ </h:outputText>
+ </div>
</div>
+
+ <div class="clear"></div>
</div>
</div>
</h:column>
</h:dataTable>
+
+ <div id="totals_container">
+ Gesamtsumme:
+ <h:outputText class="price" id="total_sum" value="#{basketController.calculateTotalPrice()}">
+ <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+ </h:outputText>
+ </div>
</ui:define>
<ui:define name="footer">