| ?? prefix="n2" starthook="i1" maxlinks="-1" category="Vertical1.other" vertical="1">
| ?? hook="title" category="Title.other">
<%@ page import="hotspace.servlet.http.HSCookie,
hotspace.util.HSUtil,
hotspace.model.exception.NotFoundException,
hotspace.rt.handler.shop.CheckCart,
hotspace.service.*,
hotspace.sql.DB,
com.dcx.db.*"
%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<%@ page import="org.apache.commons.logging.Log"%>
<%@ page import="org.hibernate.Session"%>
<%@ page import="com.dcx.hibernate.HibernateUtil"%>
<%!
/* Declarations for this JSP */
private static Log _scblog = LogFactory.getLog( "shoppingcartbutton/checkcart.jsp" );
%>
<%
if( request.getParameter( "hideCart" ) == null || !request.getParameter( "hideCart" ).equals( "1" ) )
{
// see if you have a cookie
RequestInterface req = Request.getInstance( request );
HSCookie cookie = new HSCookie( req, response );
if( cookie.getPersistentCookieId() == null )
{
// _scblog.error( "No cart found for: " + req.getServerName() );
}
else
{
try
{
int storeId = Integer.parseInt( "1518" );
String hideCart = null;
ShopBasket basket = new ShopBasket( cookie.getPersistentCookieId(), "www.decentrix.com", storeId );
Session dbSession = HibernateUtil.getSession( DB.DBNAME_DEFINER );
basket = (ShopBasket)dbSession.load( ShopBasket.class, basket );
if( basket != null )
{
OrderEntity order = basket.getPendingOrder();
if( HSUtil.avail( hideCart ) )
;
else
out.println( formatCartButton( req, order.getOrderEntries().size() ) );
}
else
_scblog.error( "Could not load cart: " + cookie.getPersistentCookieId() );
}
catch( Exception ex )
{
_scblog.error( "Failed to build shopping cart.", ex );
// Print nothing. we have had a problem constructing the cart.
out.println( "" );
}
}
}
%>
<%!
public String formatCartButton( RequestInterface request, int itemCount )
{
StringBuilder result = new StringBuilder();
if (itemCount > 0)
{
result.append( "| ");
result.append( "You have " );
result.append( String.valueOf( itemCount ) );
result.append( " item" );
if( itemCount != 1 )
result.append( "s" );
result.append( " in your shopping cart " );
String href = null;
String origin = request.getScheme() + "://" + request.getServerName() + ":"
+ ( request.getServerPort() == 80 ? "" : String.valueOf( request.getServerPort() ) )
+ request.getRequestURI();
href = "_cart.jsp?origin=" + origin + "&hideCart=1";
result.append( "" );
result.append( " View Cart / Checkout" );
result.append( "" );
result.append( " | " );
}
return result.toString();
}
%> |
| This page is still under construction, please excuse the buggs
|
|