<% /** * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ %> <%@ include file="/html/portlet/shopping/init.jsp" %> <% String redirect = ParamUtil.getString(request, "redirect"); ShoppingCart cart = ShoppingUtil.getCart(renderRequest); Map items = cart.getItems(); ShoppingCoupon coupon = cart.getCoupon(); boolean minQuantityMultiple = PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsUtil.SHOPPING_CART_MIN_QTY_MULTIPLE); %>
">" method="post" name="fm" onSubmit="saveCart(); return false;"> <% CartMinQuantityException cmqe = (CartMinQuantityException)errorException; long[] badItemIds = StringUtil.split(cmqe.getMessage(), 0L); %>



<% for (int i = 0; i < badItemIds.length; i++) { ShoppingItem item = ShoppingItemLocalServiceUtil.getItem(badItemIds[i]); %> <%= item.getSku() %>, <% } %>
<% SearchContainer searchContainer = new SearchContainer(); List headerNames = new ArrayList(); headerNames.add("sku"); headerNames.add("description"); headerNames.add("quantity"); headerNames.add("price"); searchContainer.setHeaderNames(headerNames); searchContainer.setEmptyResultsMessage("your-cart-is-empty"); searchContainer.setHover(false); Set results = items.entrySet(); int total = items.size(); searchContainer.setTotal(total); List resultRows = searchContainer.getResultRows(); itr = results.iterator(); for (int i = 0; itr.hasNext(); i++) { Map.Entry entry = (Map.Entry)itr.next(); ShoppingCartItem cartItem = (ShoppingCartItem)entry.getKey(); Integer count = (Integer)entry.getValue(); ShoppingItem item = cartItem.getItem(); String[] fieldsArray = cartItem.getFieldsArray(); ShoppingItemField[] itemFields = (ShoppingItemField[])ShoppingItemFieldLocalServiceUtil.getItemFields(item.getItemId()).toArray(new ShoppingItemField[0]); ShoppingItemPrice[] itemPrices = (ShoppingItemPrice[])ShoppingItemPriceLocalServiceUtil.getItemPrices(item.getItemId()).toArray(new ShoppingItemPrice[0]); if (!SessionErrors.isEmpty(renderRequest)) { count = new Integer(ParamUtil.getInteger(request, "item_" + item.getItemId() + "_" + i + "_count")); } ResultRow row = new ResultRow(item, item.getItemId(), i); PortletURL rowURL = renderResponse.createRenderURL(); rowURL.setWindowState(WindowState.MAXIMIZED); rowURL.setParameter("struts_action", "/shopping/view_item"); rowURL.setParameter("itemId", String.valueOf(item.getItemId())); // SKU and small image StringMaker sm = new StringMaker(); if (item.isSmallImage()) { sm.append("
"); sm.append("\"");"); } else { sm.append(""); sm.append(item.getSku()); sm.append(""); } row.addText(sm.toString(), rowURL); // Description sm = new StringMaker(); sm.append(item.getName()); sm.append(""); if (Validator.isNotNull(item.getDescription())) { sm.append("
"); sm.append(item.getDescription()); } /*Properties props = new OrderedProperties(); PropertiesUtil.load(props, item.getProperties()); Enumeration enu = props.propertyNames(); while (enu.hasMoreElements()) { String propsKey = (String)enu.nextElement(); String propsValue = props.getProperty(propsKey, StringPool.BLANK); sm.append("
"); sm.append(propsKey); sm.append(": "); sm.append(propsValue); }*/ if (PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsUtil.SHOPPING_ITEM_SHOW_AVAILABILITY)) { sm.append("

"); if (ShoppingUtil.isInStock(item, itemFields, fieldsArray, count)) { sm.append(LanguageUtil.get(pageContext, "availability")); sm.append(": "); sm.append(""); sm.append(LanguageUtil.get(pageContext, "in-stock")); sm.append(""); } else { sm.append(LanguageUtil.get(pageContext, "availability")); sm.append(": "); sm.append(""); sm.append(LanguageUtil.get(pageContext, "out-of-stock")); sm.append(""); sm.append(""); } } if (fieldsArray.length > 0) { sm.append("
"); } for (int j = 0; j < fieldsArray.length; j++) { int pos = fieldsArray[j].indexOf("="); String fieldName = fieldsArray[j].substring(0, pos); String fieldValue = fieldsArray[j].substring(pos + 1, fieldsArray[j].length()); sm.append("
"); sm.append(fieldName); sm.append(": "); sm.append(fieldValue); } if (itemPrices.length > 0) { sm.append("
"); } for (int j = 0; j < itemPrices.length; j++) { ShoppingItemPrice itemPrice = itemPrices[j]; sm.append("
"); if ((itemPrice.getMinQuantity() == 0) && (itemPrice.getMaxQuantity() == 0)) { sm.append(LanguageUtil.get(pageContext, "price")); sm.append(": "); } else if (itemPrice.getMaxQuantity() != 0) { sm.append(LanguageUtil.format(pageContext, "price-for-x-to-x-items", new Object[] {"" + new Integer(itemPrice.getMinQuantity()) + "", "" + new Integer(itemPrice.getMaxQuantity()) + ""}, false)); } else if (itemPrice.getMaxQuantity() == 0) { sm.append(LanguageUtil.format(pageContext, "price-for-x-items-and-above", "" + new Integer(itemPrice.getMinQuantity()) + "", false)); } if (itemPrice.getDiscount() <= 0) { sm.append(currencyFormat.format(itemPrice.getPrice())); } else { sm.append(""); sm.append(currencyFormat.format(itemPrice.getPrice())); sm.append(" "); sm.append(""); sm.append(currencyFormat.format(ShoppingUtil.calculateActualPrice(itemPrice))); sm.append(" / "); sm.append(LanguageUtil.get(pageContext, "you-save")); sm.append(": "); sm.append(""); sm.append(currencyFormat.format(ShoppingUtil.calculateDiscountPrice(itemPrice))); sm.append(" ("); sm.append(percentFormat.format(itemPrice.getDiscount())); sm.append(")"); sm.append(""); } } sm.append("
"); row.addText(sm.toString(), rowURL); // Quantity sm = new StringMaker(); if (minQuantityMultiple && (item.getMinQuantity() > 0)) { sm.append(""); } else { sm.append(""); } row.addText(sm.toString()); // Price row.addText(currencyFormat.format(ShoppingUtil.calculateActualPrice(item, count.intValue()) / count.intValue()), rowURL); // Add result row resultRows.add(row); } %>
<% double insurance = ShoppingUtil.calculateInsurance(items); %>
: <% double subtotal = ShoppingUtil.calculateSubtotal(items); double actualSubtotal = ShoppingUtil.calculateActualSubtotal(items); double discountSubtotal = ShoppingUtil.calculateDiscountSubtotal(items); %> <%= currencyFormat.format(subtotal) %> <%= currencyFormat.format(subtotal) %> <%= currencyFormat.format(actualSubtotal) %>
: <%= currencyFormat.format(discountSubtotal) %> (<%= percentFormat.format(ShoppingUtil.calculateDiscountPercent(items)) %>)

: <%= currencyFormat.format(ShoppingUtil.calculateShipping(items)) %>

:

: ">', 'viewCoupon', 'directories=no,height=200,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=280'); void(''); viewCouponWindow.focus();" style="font-size: xx-small;">()
: <%= currencyFormat.format(ShoppingUtil.calculateCouponDiscount(items, coupon)) %>

<% String[] ccTypes = shoppingPrefs.getCcTypes(); if (shoppingPrefs.usePayPal()) { %>

<% } else if (!shoppingPrefs.usePayPal() && (ccTypes.length > 0)) { for (int i = 0; i < ccTypes.length; i++) { %> <% } %>

<% } %> " onClick="updateCart();" /> " onClick="emptyCart();" /> " onClick="checkout();" />