BrightSide Workbench Full Report + Source Code
org.turro.financials.cart.ShoppingCart Class Reference

Public Member Functions

 ShoppingCart (IConstructor constructor, String shopping, String template)
 
void renderCart ()
 
String getUrlForRemoveFromCart (int order)
 
String getUrlForChangeFromCart (int order)
 
String getUrlForShopping ()
 
String getUrlForCheckout ()
 

Static Public Member Functions

static Cart getCart (IConstructor constructor)
 
static void removeCart (IConstructor constructor)
 
static String getAddToCart (String product, String quantity, String price)
 
static Double getStockForProduct (IConstructor constructor, long id)
 
static Double getStockForProduct (IConstructor constructor, Product product)
 

Detailed Description

Uses a session attribute to manage a Cart object. Also checks whether a user is authenticated to perform the checkout.

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 40 of file ShoppingCart.java.

Constructor & Destructor Documentation

◆ ShoppingCart()

org.turro.financials.cart.ShoppingCart.ShoppingCart ( IConstructor  constructor,
String  shopping,
String  template 
)

Definition at line 46 of file ShoppingCart.java.

46  {
47  this.constructor = constructor;
48  this.shopping = shopping;
49  this.template = template;
50  checkCart();
51  }

Member Function Documentation

◆ getAddToCart()

static String org.turro.financials.cart.ShoppingCart.getAddToCart ( String  product,
String  quantity,
String  price 
)
static

Definition at line 150 of file ShoppingCart.java.

150  {
151  return Actions.createRightNowParameter(
152  "addToCart=" + product +
153  ";quantity=" + quantity +
154  ";price=" + price);
155  }
Here is the call graph for this function:

◆ getCart()

static Cart org.turro.financials.cart.ShoppingCart.getCart ( IConstructor  constructor)
static

Definition at line 125 of file ShoppingCart.java.

125  {
126  Cart cart = (Cart) constructor.getSessionAttribute(ElephantContext.getRootWebPath() + ShopContext.getInstance().getCartPath() + "-cart");
127  IContact contact = Authentication.getIContact();
128  if(cart == null) {
129  cart = new Cart();
130  constructor.setSessionAttribute(ElephantContext.getRootWebPath() + ShopContext.getInstance().getCartPath() + "-cart", cart);
131  if(contact == null) {
132  constructor.setSessionAttribute(IRegisterCallback.REGISTER_CALLBACK_KEY, cart);
133  }
134  }
135  if(contact != null && cart.getItems().isEmpty()) {
136  Cart serCart = Cart.deserializeFor(contact);
137  if(serCart != null) {
138  cart = serCart;
139  constructor.setSessionAttribute(ElephantContext.getRootWebPath() + ShopContext.getInstance().getCartPath() + "-cart", cart);
140  Cart.removeFor(contact);
141  }
142  }
143  return cart;
144  }
void setSessionAttribute(String key, Object value)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStockForProduct() [1/2]

static Double org.turro.financials.cart.ShoppingCart.getStockForProduct ( IConstructor  constructor,
long  id 
)
static

Definition at line 157 of file ShoppingCart.java.

157  {
158  Cart cart = getCart(constructor);
159  return getStock(cart, id);
160  }
static Cart getCart(IConstructor constructor)
Here is the call graph for this function:

◆ getStockForProduct() [2/2]

static Double org.turro.financials.cart.ShoppingCart.getStockForProduct ( IConstructor  constructor,
Product  product 
)
static

Definition at line 162 of file ShoppingCart.java.

162  {
163  Cart cart = getCart(constructor);
164  return getStock(cart, product);
165  }
Here is the call graph for this function:

◆ getUrlForChangeFromCart()

String org.turro.financials.cart.ShoppingCart.getUrlForChangeFromCart ( int  order)

Definition at line 64 of file ShoppingCart.java.

64  {
65  return Actions.createRightNowParameter("changeFromCart=" + order);
66  }
Here is the call graph for this function:

◆ getUrlForCheckout()

String org.turro.financials.cart.ShoppingCart.getUrlForCheckout ( )

Definition at line 73 of file ShoppingCart.java.

73  {
74  IContact contact = Authentication.getIContact();
75  if(contact == null || !contact.isWebUser()) {
76  return ElephantContext.getRootWebPath() + "/user";
77  } else {
78  return ElephantContext.getRootWebPath() + ShopContext.getInstance().getCheckoutPath();
79  }
80  }
Here is the call graph for this function:

◆ getUrlForRemoveFromCart()

String org.turro.financials.cart.ShoppingCart.getUrlForRemoveFromCart ( int  order)

Definition at line 60 of file ShoppingCart.java.

60  {
61  return Actions.createRightNowParameter("delFromCart=" + order);
62  }
Here is the call graph for this function:

◆ getUrlForShopping()

String org.turro.financials.cart.ShoppingCart.getUrlForShopping ( )

Definition at line 68 of file ShoppingCart.java.

68  {
69  return ElephantContext.getRootWebPath() +
70  shopping;
71  }
Here is the call graph for this function:

◆ removeCart()

static void org.turro.financials.cart.ShoppingCart.removeCart ( IConstructor  constructor)
static

Definition at line 146 of file ShoppingCart.java.

146  {
147  constructor.removeSessionAttribute(ElephantContext.getRootWebPath() + ShopContext.getInstance().getCartPath() + "-cart");
148  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderCart()

void org.turro.financials.cart.ShoppingCart.renderCart ( )

Definition at line 53 of file ShoppingCart.java.

53  {
54  ElephantMarker marker = new ElephantMarker(constructor);
55  marker.put("shoppingCart", this);
56  marker.put("cart", cart);
57  marker.process("cart", getTemplate());
58  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: