<%@ include file="/header.jsp" %> <%@ include file="/getLogin.jsp" %> <%@ include file="/title.jsp" %> <%@ include file="/utils.jsp" %>

Shopping Cart

<% String action = parser.getStringParameter("action",null); Cartitem cartitem = null; String cartitemPK = parser.getStringParameter("cartitem",null); if ( cartitemPK != null ) { cartitem = new Cartitem(); try { cartitem.findByPrimaryKey(con, cartitemPK); int quant = parser.getIntParameter("quant",-1); if ( quant == 0 ) { cartitem.remove(con); } else if ( quant > 0 ) { cartitem.setQuant( String.valueOf( quant ) ); cartitem.store(con); } } catch ( Exception e ) { } // ignore cartitem = null; } double price_total = 0; String color = null; Cartitem[] cartitems = usern.getCartitems(con, new Where(), new Orderby("customershipto")); Customershipto cst = new Customershipto(); for ( int i = 0 ; i < cartitems.length ; i++ ) { if ( ! cartitems[i].getCustomershipto().equals( cst.getCustomershipto() ) ) { cst.findByPrimaryKey(con, cartitems[i].getCustomershipto()); %> <% } ItemBean item = new ItemBean(); item.findByPrimaryKey(con, cartitems[i].getItem()); int quant = Integer.valueOf( cartitems[i].getQuant() ).intValue(); double price = 0; String saleString = ""; if ( usern.getUsern() != null ) { double usern_price = 0; double sale_price = 0; usern_price = Double.valueOf( item.getPrice( con , usern.getUsern() ) ).doubleValue(); if ( "Y".equals(item.getOnsale()) && item.getPricesale() != null ) { sale_price = Double.valueOf( item.getPricesale() ).doubleValue(); if ( sale_price < usern_price ) { price = sale_price; } else { price = usern_price; } } else { price = usern_price; } } else { if ( "Y".equals(item.getOnsale()) && item.getPricesale() != null ) { saleString = "On sale from " + moneyFormatter.format( Double.valueOf( item.getPrice() ).doubleValue() ) + " "; price = Double.valueOf( item.getPricesale() ).doubleValue(); } else { price = Double.valueOf( item.getPrice() ).doubleValue(); } } double price_line = price * quant; price_total += price_line; color = next_color(color); %> <% } if ( cartitems.length < 1 ) { %> <% } %>
The following items will be shipped to:
<%= formatCst( cst ) %>
Quant Desc Price Total
<%= item.getTitle() %> <%= formatMoney( String.valueOf(price) ) %> <%= saleString %><%= moneyFormatter.format( price_line ) %>
You have no items in your cart
Sub-total <%= moneyFormatter.format( price_total ) %>
<% String categoryPK = (String) session.getAttribute("category"); if ( categoryPK != null ) { %> <% } %> <% if ( cartitems.length > 0 ) { %> <%= new MessagesBean(con,"cart_to_invoice_warning") %> <% } %>
">
-->">
<%= Projectlib.explainShipping(con) %>
<%= print_popup(session) %> <%@ include file="/foot.jsp"%> <%! public static String formatCst(Customershipto cst) { StringBuffer o = new StringBuffer(); o.append("
"); o.append(cst.getName()); o.append("
"); o.append(cst.getAddress1()); o.append("
"); if ( cst.getAddress2() != null ) { o.append(cst.getAddress2()); o.append("
"); } o.append( cst.getCity() ); o.append(", "); o.append( cst.getState() ); o.append(" "); o.append( cst.getZip() ); o.append("
"); return o.toString(); } String next_color(String s) { if ("#ffffdd".equals(s)) return "#ffffcc"; return "#ffffdd"; } %>