Package com.jada.order.cart

Examples of com.jada.order.cart.ShoppingCart


    public ActionForward start(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
     
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      ContentBean contentBean = getContentBean(request);
      PaymentGateway paymentGateway = contentBean.getContentSessionBean().getSiteCurrency().getPayPalPaymentGateway();
      PayPalEngine payPalEngine = new PayPalEngine(contentBean.getContentSessionBean().getSiteDomain().getSite(), paymentGateway.getPaymentGatewayId());
      payPalEngine.setSiteDomain(contentBean.getContentSessionBean().getSiteDomain());
      shoppingCart.setPaymentEngine(payPalEngine);
     
    OrderEngine orderEngine = new OrderEngine(shoppingCart, null);
    OrderHeader orderHeader = orderEngine.getOrderHeader();
    payPalEngine.payPalAuthorizePayment(orderHeader, request);
    String token = payPalEngine.getToken();
View Full Code Here


            em = JpaConnection.getInstance().getCurrentEntityManager();
            em.getTransaction().begin();
            ContentBean contentBean = new ContentBean();
          contentBean.init(request);
          setContentBean(contentBean, request);
          ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, false);
          if (shoppingCart != null) {
            synchronized (this) {
              shoppingCart.setSiteCurrency(contentBean.getContentSessionBean().getSiteCurrency());
              shoppingCart.recalculate(contentBean);
            }
          }
           
          String enforceProtocol = mapping.getEnforceProtocol();
          if (Format.isNullOrEmpty(enforceProtocol)) {
View Full Code Here

     
      init(request);
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ContentBean contentBean = getContentBean(request);
      Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
    ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
    maintainOpenOrder(request, shoppingCart);
      ActionMessages messages = new ActionMessages();
      CustomerAddress customerAddress = shoppingCart.getEstimateAddress();
      if (customerAddress != null) {
        form.setEstimateCountryCode(customerAddress.getCustCountryCode());
        form.setEstimateStateCode(customerAddress.getCustStateCode());
        form.setEstimateZipCode(customerAddress.getCustZipCode());
      }
     
    this.initSearchInfo(form, site.getSiteId(), messages);
    this.initCartInfo(form, site, shoppingCart, request, messages);
    if (customerAddress != null) {
          if (!shoppingCart.isShippingValid()) {
            messages.add("estimateShippingLocation", new ActionMessage("content.error.shippingLocation.unsupported"));
          }
    }
    saveMessages(request, messages);
        String sequenceInterrupt = request.getParameter("sequenceInterrupt");
View Full Code Here

     
      init(request);
    ContentBean contentBean = getContentBean(request);
    Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
    ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
    ActionMessages messages = new ActionMessages();
   
      try {
      String itemAttribDetailIds[] = form.getItemAttribDetailIds();
      Vector<ItemAttributeInfo> itemAttributeInfos = new Vector<ItemAttributeInfo>();
      if (itemAttribDetailIds != null) {
        String customAttribValues[] = form.getCustomAttribValues();
        String customAttribTypeCodes[] = form.getCustomAttribTypeCodes();
        for (int i = 0; i < itemAttribDetailIds.length; i++) {
          ItemAttributeInfo itemAttributeInfo = new ItemAttributeInfo();
          itemAttributeInfo.setCustomAttribTypeCode(customAttribTypeCodes[i]);
          itemAttributeInfo.setItemAttribDetailId(Format.getLong(itemAttribDetailIds[i]));
          if (customAttribTypeCodes[i].equals(String.valueOf(Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT))) {
            itemAttributeInfo.setItemAttribDetailValue(customAttribValues[i]);
          }
          else {
            itemAttributeInfo.setCustomAttribOptionId(Format.getLong(customAttribValues[i]));
          }
          itemAttributeInfos.add(itemAttributeInfo);
        }
      }
     
        Language language = contentBean.getContentSessionBean().getSiteProfile().getSiteProfileClass().getLanguage();
          String itemNauralKeys[] = form.getItemNaturalKeys();
          if (itemNauralKeys != null) {
            for (int i = 0; i < itemNauralKeys.length; i++) {
              Item item = DataApi.getInstance().getItem(site.getSiteId(), itemNauralKeys[i]);
              try {
              if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_RECOMMAND_BUNDLE)) {
                for (Item child : item.getChildren()) {
                  shoppingCart.setItemQty(child, 1, itemAttributeInfos, contentBean, false);
                }
              }
              else if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_TEMPLATE)) {
                item = getItem(form, site.getSiteId());
                shoppingCart.setItemQty(item, 1, itemAttributeInfos, contentBean, false);
              }
              else {
                shoppingCart.setItemQty(item, 1, itemAttributeInfos, contentBean, false);
              }
              } catch (ItemNotAvailiableException itemNotAvailiableException) {
                String value = Languages.getLangTranValue(language.getLangId(), "content.text.itemQuatityNotAvailable");
              ShoppingCartItemBean itemInfo = (ShoppingCartItemBean) form.getShoppingCartItemInfos().elementAt(i);
              itemInfo.setItemQtyError(value);
              }
            }
          }
          else {
            /*
             * Only intended to be used with older version of templates.
             */
            String itemIds[] = form.getItemIds();
            if (itemIds != null) {
              for (int i = 0; i < itemIds.length; i++) {
                Item item = DataApi.getInstance().getItem(site.getSiteId(), Format.getLong(itemIds[i]));
              if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_RECOMMAND_BUNDLE)) {
                for (Item child : item.getChildren()) {
                  shoppingCart.setItemQty(child, 1, itemAttributeInfos, contentBean, false);
                }
              }
              else if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_TEMPLATE)) {
                item = getItem(form, site.getSiteId());
                shoppingCart.setItemQty(item, 1, itemAttributeInfos, contentBean, false);
              }
              else {
                shoppingCart.setItemQty(item, 1, itemAttributeInfos, contentBean, false);
              }
              }
            }
          }
      } catch (ItemNotAvailiableException itemNotAvailiableException) {
View Full Code Here

     
      init(request);
      ContentBean contentBean = getContentBean(request);
    Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      ActionMessages messages = new ActionMessages();
    shoppingCart.removeItem(form.getItemNaturalKey(), getContentBean(request));
   
    maintainOpenOrder(request, shoppingCart);

    this.initSearchInfo(form, site.getSiteId(), messages);
    this.initCartInfo(form, site, shoppingCart, request, messages);
View Full Code Here

     
      init(request);
      ContentBean contentBean = getContentBean(request);
    Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      shoppingCart.setShippingQuoteLock(false);
    this.uplockShippingQuote(shoppingCart, Constants.ORDER_STEP_REVIEWPURCHASE);
      ActionMessages messages = new ActionMessages();
    this.initSearchInfo(form, site.getSiteId(), messages);
    this.initCartInfo(form, site, shoppingCart, request, messages);
    createEmptySecureTemplateInfo(request);
View Full Code Here

     
      init(request);
      ContentBean contentBean = getContentBean(request);
    Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      ActionMessages messages = new ActionMessages();
    shoppingCart.removeCoupon(Format.getLong(form.getCouponId()), getContentBean(request));
   
    maintainOpenOrder(request, shoppingCart);
   
    this.initSearchInfo(form, site.getSiteId(), messages);
    this.initCartInfo(form, site, shoppingCart, request, messages);
View Full Code Here

     
      init(request);
      ContentBean contentBean = getContentBean(request);
    Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      ActionMessages messages = new ActionMessages();
      this.initCartInfo(form, site, shoppingCart, request, messages);
      boolean hasError = validateUpdateQty(form, getContentBean(request));
      if (hasError) {
          String itemNaturalKeys[] = form.getItemNaturalKeys();
          String itemQtys[] = form.getItemQtys();
        for (int i = 0; i < itemNaturalKeys.length; i++) {
          ShoppingCartItemBean bean = (ShoppingCartItemBean) form.getShoppingCartItemInfos().elementAt(i);
          bean.setItemQty(itemQtys[i]);
        }
      }
      else {
          String itemNaturalKeys[] = form.getItemNaturalKeys();
          String itemQtys[] = form.getItemQtys();
          if (itemNaturalKeys != null) {
            for (int i = 0; i < itemNaturalKeys.length; i++) {
              int qty = 0;
              if (itemQtys[i].trim().length() != 0) {
                qty = Format.getInt(itemQtys[i]);
              }
              Item item = DataApi.getInstance().getItem(site.getSiteId(), itemNaturalKeys[i]);
          try {
            shoppingCart.setItemQty(item, qty, null, getContentBean(request), true);
          }
          catch (ItemNotAvailiableException e) {
               messages.add("message", new ActionMessage("content.text.itemQuatityNotAvailable"));
          }
            }
View Full Code Here

            HttpServletResponse response)
        throws Throwable {
      ContentBean contentBean = getContentBean(request);
    Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      String couponCode = form.getCouponCode().toUpperCase();
    createEmptySecureTemplateInfo(request);
      ActionMessages messages = new ActionMessages();
      this.initSearchInfo(form, site.getSiteId(), messages);
      if (Format.isNullOrEmpty(couponCode)) {
        this.initCartInfo(form, site, shoppingCart, request, messages);
        messages.add("couponCode", new ActionMessage("content.error.string.required"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }
     
        Coupon coupon = CouponDAO.loadByCouponCode(site.getSiteId(), couponCode);
        if (coupon == null) {
          this.initCartInfo(form, site, shoppingCart, request, messages);
        messages.add("couponCode", new ActionMessage("content.error.coupon.invalid"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
       
    try {
      shoppingCart.addCoupon(coupon, getContentBean(request));
    }
    catch (CouponNotApplicableException e1) {
      this.initCartInfo(form, site, shoppingCart, request, messages);
        messages.add("couponCode", new ActionMessage("content.error.coupon.notApplicable"));
      saveMessages(request, messages);
View Full Code Here

            HttpServletResponse response)
        throws Throwable {
      ContentBean contentBean = getContentBean(request);
    Site site = contentBean.getContentSessionBean().getSiteDomain().getSite();
      ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
      ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
      shoppingCart.setEstimateAddress(request, form.getEstimateCountryCode(), form.getEstimateStateCode(), form.getEstimateZipCode(), form.isEstimatePickUp());
      shoppingCart.recalculate(contentBean);
     
      ActionMessages messages = new ActionMessages();
      this.initSearchInfo(form, site.getSiteId(), messages);
    this.initCartInfo(form, site, shoppingCart, request, messages);
      if (!shoppingCart.isShippingValid() && !form.isEstimatePickUp()) {
        messages.add("estimateShippingLocation", new ActionMessage("content.error.shippingLocation.unsupported"));
      }
    saveMessages(request, messages);
    createEmptySecureTemplateInfo(request);
        ActionForward actionForward = actionMapping.findForward("success");
View Full Code Here

TOP

Related Classes of com.jada.order.cart.ShoppingCart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.