|
[ https://issues.apache.org/jira/browse/OFBIZ-10424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16589091#comment-16589091 ] Deepak Nigam commented on OFBIZ-10424: -------------------------------------- Hi [~nk_smallbee], I am able to reproduce the issue reported by you on the trunk. However, you can use 'CartAbandonedLine' entity for the same. For more information have a look at the file plugins/ecommerce/webapp/ecommerce/WEB-INF/web.xml {code:java} <!-- this listener will save any abandoned cart info --> <listener><listener-class>org.apache.ofbiz.order.shoppingcart.CartEventListener</listener-class></listener> {code} and /applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/CartEventListener.java {code:java} @Override public void sessionDestroyed(HttpSessionEvent event) { HttpSession session = event.getSession(); ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingCart"); if (cart == null) { Debug.logInfo("No cart to save, doing nothing.", module); return; } String delegatorName = (String) session.getAttribute("delegatorName"); Delegator delegator = null; if (UtilValidate.isNotEmpty(delegatorName)) { delegator = DelegatorFactory.getDelegator(delegatorName); } if (delegator == null) { Debug.logError("Could not find delegator with delegatorName in session, not saving abandoned cart info.", module); return; } boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); GenericValue visit = VisitHandler.getVisit(session); if (visit == null) { Debug.logInfo("Could not get the current visit, not saving abandoned cart info.", module); return; } Debug.logInfo("Saving abandoned cart", module); int seqId = 1; for (ShoppingCartItem cartItem : cart) { GenericValue cartAbandonedLine = delegator.makeValue("CartAbandonedLine"); cartAbandonedLine.set("visitId", visit.get("visitId")); cartAbandonedLine.set("cartAbandonedLineSeqId", Integer.toString(seqId)); cartAbandonedLine.set("productId", cartItem.getProductId()); cartAbandonedLine.set("prodCatalogId", cartItem.getProdCatalogId()); cartAbandonedLine.set("quantity", cartItem.getQuantity()); cartAbandonedLine.set("reservStart", cartItem.getReservStart()); cartAbandonedLine.set("reservLength", cartItem.getReservLength()); cartAbandonedLine.set("reservPersons", cartItem.getReservPersons()); cartAbandonedLine.set("unitPrice", cartItem.getBasePrice()); cartAbandonedLine.set("reserv2ndPPPerc", cartItem.getReserv2ndPPPerc()); cartAbandonedLine.set("reservNthPPPerc", cartItem.getReservNthPPPerc()); if (cartItem.getConfigWrapper() != null) { cartAbandonedLine.set("configId", cartItem.getConfigWrapper().getConfigId()); } cartAbandonedLine.set("totalWithAdjustments", cartItem.getItemSubTotal()); //not doing pre-reservations now, so this is always N cartAbandonedLine.set("wasReserved", "N"); cartAbandonedLine.create(); seqId++; } } catch (GenericEntityException e) { try { // only rollback the transaction if we started one... TransactionUtil.rollback(beganTransaction, "Error saving abandoned cart info", e); } catch (GenericEntityException e2) { Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), module); } Debug.logError(e, "An entity engine error occurred while saving abandoned cart information", module); } finally { // only commit the transaction if we started one... this will throw an exception if it fails try { TransactionUtil.commit(beganTransaction); } catch (GenericEntityException e) { Debug.logError(e, "Could not commit transaction for entity engine error occurred while saving abandoned cart information", module); } } } {code} > After login shopping cart is cleared. > ------------------------------------- > > Key: OFBIZ-10424 > URL: https://issues.apache.org/jira/browse/OFBIZ-10424 > Project: OFBiz > Issue Type: Bug > Components: ecommerce > Affects Versions: Trunk > Reporter: Jason Hao > Priority: Major > > Open ecommerce page, add some product to shopping cart, and click one page checkout, login with admin/ofbiz, the it will display the Main page, and shopping cart is cleared. -- This message was sent by Atlassian JIRA (v7.6.3#76005) |
| Free forum by Nabble | Edit this page |
