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.
◆ ShoppingCart()
org.turro.financials.cart.ShoppingCart.ShoppingCart |
( |
IConstructor |
constructor, |
|
|
String |
shopping, |
|
|
String |
template |
|
) |
| |
Definition at line 46 of file ShoppingCart.java.
47 this.constructor = constructor;
48 this.shopping = shopping;
49 this.
template =
template;
◆ getAddToCart()
static String org.turro.financials.cart.ShoppingCart.getAddToCart |
( |
String |
product, |
|
|
String |
quantity, |
|
|
String |
price |
|
) |
| |
|
static |
Definition at line 150 of file ShoppingCart.java.
151 return Actions.createRightNowParameter(
152 "addToCart=" + product +
153 ";quantity=" + quantity +
◆ getCart()
static Cart org.turro.financials.cart.ShoppingCart.getCart |
( |
IConstructor |
constructor | ) |
|
|
static |
Definition at line 125 of file ShoppingCart.java.
126 Cart cart = (Cart) constructor.
getSessionAttribute(ElephantContext.getRootWebPath() + ShopContext.getInstance().getCartPath() +
"-cart");
127 IContact contact = Authentication.getIContact();
130 constructor.
setSessionAttribute(ElephantContext.getRootWebPath() + ShopContext.getInstance().getCartPath() +
"-cart", cart);
131 if(contact ==
null) {
135 if(contact !=
null && cart.getItems().isEmpty()) {
136 Cart serCart = Cart.deserializeFor(contact);
137 if(serCart !=
null) {
139 constructor.
setSessionAttribute(ElephantContext.getRootWebPath() + ShopContext.getInstance().getCartPath() +
"-cart", cart);
140 Cart.removeFor(contact);
void setSessionAttribute(String key, Object value)
Object getSessionAttribute(String key)
◆ getStockForProduct() [1/2]
static Double org.turro.financials.cart.ShoppingCart.getStockForProduct |
( |
IConstructor |
constructor, |
|
|
long |
id |
|
) |
| |
|
static |
◆ getStockForProduct() [2/2]
static Double org.turro.financials.cart.ShoppingCart.getStockForProduct |
( |
IConstructor |
constructor, |
|
|
Product |
product |
|
) |
| |
|
static |
◆ getUrlForChangeFromCart()
String org.turro.financials.cart.ShoppingCart.getUrlForChangeFromCart |
( |
int |
order | ) |
|
Definition at line 64 of file ShoppingCart.java.
65 return Actions.createRightNowParameter(
"changeFromCart=" + order);
◆ getUrlForCheckout()
String org.turro.financials.cart.ShoppingCart.getUrlForCheckout |
( |
| ) |
|
Definition at line 73 of file ShoppingCart.java.
74 IContact contact = Authentication.getIContact();
75 if(contact ==
null || !contact.isWebUser()) {
76 return ElephantContext.getRootWebPath() +
"/user";
78 return ElephantContext.getRootWebPath() + ShopContext.getInstance().getCheckoutPath();
◆ getUrlForRemoveFromCart()
String org.turro.financials.cart.ShoppingCart.getUrlForRemoveFromCart |
( |
int |
order | ) |
|
Definition at line 60 of file ShoppingCart.java.
61 return Actions.createRightNowParameter(
"delFromCart=" + order);
◆ getUrlForShopping()
String org.turro.financials.cart.ShoppingCart.getUrlForShopping |
( |
| ) |
|
◆ removeCart()
static void org.turro.financials.cart.ShoppingCart.removeCart |
( |
IConstructor |
constructor | ) |
|
|
static |
Definition at line 146 of file ShoppingCart.java.
147 constructor.
removeSessionAttribute(ElephantContext.getRootWebPath() + ShopContext.getInstance().getCartPath() +
"-cart");
void removeSessionAttribute(String key)
◆ renderCart()
void org.turro.financials.cart.ShoppingCart.renderCart |
( |
| ) |
|
Definition at line 53 of file ShoppingCart.java.
54 ElephantMarker marker =
new ElephantMarker(constructor);
55 marker.put(
"shoppingCart",
this);
56 marker.put(
"cart", cart);
57 marker.process(
"cart", getTemplate());
The documentation for this class was generated from the following file: