Package com.jada.order.cart

Examples of com.jada.order.cart.ShoppingCartItem


    double priceTotal = 0;
    if (shoppingCart != null) {
      Vector<?> vector = shoppingCart.getShoppingCartItems();
      Iterator<?> iterator = vector.iterator();
      while (iterator.hasNext()) {
        ShoppingCartItem shoppingCartItem = (ShoppingCartItem) iterator.next();
        ItemInfo itemInfo = formatItem(shoppingCartItem.getItem());
        itemInfo.setItemOrderedQty(Format.getInt(shoppingCartItem.getItemQty()));
        itemVector.add(itemInfo);
      }
      itemCount = shoppingCart.getItemCount();
      priceTotal = shoppingCart.getPriceTotal();
    }
View Full Code Here


    orderHeader.getOrderTaxes().clear();
   
    Iterator<?> shoppingCartItems = shoppingCart.getShoppingCartItems().iterator();
    int seqNum = 0;
    while (shoppingCartItems.hasNext()) {
      ShoppingCartItem shoppingCartItem = (ShoppingCartItem) shoppingCartItems.next();
      OrderItemDetail orderItemDetail = new OrderItemDetail();
      Item item = shoppingCartItem.getItem();
      Item master = item;
      if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
        master = item.getItemSkuParent();
      }
      orderItemDetail.setSeqNum(Integer.valueOf(seqNum++));
      orderItemDetail.setItemNum(item.getItemNum());
      orderItemDetail.setItemUpcCd(item.getItemUpcCd());
orderItemDetail.setItemSkuCd(item.getItemSkuCd());
      orderItemDetail.setItemShortDesc(master.getItemLanguage().getItemShortDesc());
      if (master.getItemLanguage().getItemShortDesc().length() > 128) {
        orderItemDetail.setItemShortDesc(master.getItemLanguage().getItemShortDesc().substring(0, 127));
      }
      if (!contentSessionKey.isSiteProfileClassDefault()) {
        for (ItemLanguage language : master.getItemLanguages()) {
          if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentSessionKey.getSiteProfileClassId())) {
            if (language.getItemShortDesc() != null) {
              orderItemDetail.setItemShortDesc(language.getItemShortDesc());
            }
            break;
          }
        }
      }
      orderItemDetail.setItemTierQty(shoppingCartItem.getTierPrice().getItemTierQty());
      orderItemDetail.setItemTierPrice(shoppingCartItem.getTierPrice().getItemTierPrice());
      orderItemDetail.setItemOrderQty(shoppingCartItem.getItemQty());
      orderItemDetail.setItemDetailAmount(shoppingCartItem.getItemPriceTotal());
      orderItemDetail.setItemDetailDiscountAmount(shoppingCartItem.getItemDiscountAmount());
      setDirty(shoppingCartItem.getItem().getItemSkuCd());
      if (shoppingCartItem.getItem().getItemId() != -1L) {
        orderItemDetail.setItem(item);
      }
      orderItemDetail.setOrderHeader(orderHeader);
     
      Iterator<?> iterator = shoppingCartItem.getItemAttributeInfos().iterator();
      while (iterator.hasNext()) {
        ItemAttributeInfo itemAttributeInfo = (ItemAttributeInfo) iterator.next();
        ItemAttributeDetail itemAttributeDetail = (ItemAttributeDetail) em.find(ItemAttributeDetail.class, itemAttributeInfo.getItemAttribDetailId());
        char customAttribTypeCode = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute().getCustomAttribTypeCode();
        if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) {
          continue;
        }
        if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_INPUT) {
          continue;
        }
        if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_SELECT_DROPDOWN) {
          continue;
        }
        OrderAttributeDetail orderAttributeDetail = new OrderAttributeDetail();
        orderAttributeDetail.setOrderItemDetail(orderItemDetail);
        orderAttributeDetail.setCustomAttributeDetail(itemAttributeDetail.getCustomAttributeDetail());
        if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_SELECT_DROPDOWN) {
          CustomAttributeOption customAttributeOption = (CustomAttributeOption) em.find(CustomAttributeOption.class, itemAttributeInfo.getCustomAttribOptionId());
          orderAttributeDetail.setCustomAttributeOption(customAttributeOption);
        }
        if (customAttribTypeCode == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) {
          orderAttributeDetail.setOrderAttribValue(itemAttributeInfo.getItemAttribDetailValue());
        }
        orderItemDetail.getOrderAttributeDetails().add(orderAttributeDetail);
      }
     
      orderHeader.getOrderItemDetails().add(orderItemDetail);
     
      ItemTax taxes[] = shoppingCartItem.getTaxes();
      for (int i = 0; i < taxes.length; i++) {
        OrderDetailTax orderDetailTax = new OrderDetailTax();
        orderDetailTax.setTaxName(taxes[i].getTax().getTaxLanguage().getTaxName());
        if (!contentSessionKey.isSiteProfileClassDefault()) {
          for (TaxLanguage language : taxes[i].getTax().getTaxLanguages()) {
View Full Code Here

        form.setShippingMethodId(shoppingCart.getShippingMethod().getShippingMethodId().toString());
      }
      Vector<ShoppingCartItemBean> vector = new Vector<ShoppingCartItemBean>();
      Iterator<?> iterator = shoppingCart.getShoppingCartItems().iterator();
      while (iterator.hasNext()) {
        ShoppingCartItem shoppingCartItem = (ShoppingCartItem) iterator.next();
        ShoppingCartItemBean bean = new ShoppingCartItemBean();
        Item item = shoppingCartItem.getItem();
        Item master = item;
        if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
          master = item.getItemSkuParent();
        }
       
        bean.setItemId(item.getItemId().toString());
        bean.setItemNum(item.getItemNum());
        bean.setItemNaturalKey(item.getItemNaturalKey());
        bean.setItemQty(Format.getInt(shoppingCartItem.getItemQty()));
        int tierQty = shoppingCartItem.getTierPrice().getItemTierQty();
        float tierPrice = shoppingCartItem.getTierPrice().getItemTierPrice();
        bean.setItemPrice(formatItemPrice(contentBean, tierQty, tierPrice));
        bean.setItemSubTotal(formatter.formatCurrency(shoppingCartItem.getItemPriceTotal()));
        bean.setItemQtyError("");
       
       
        bean.setItemShortDesc(master.getItemLanguage().getItemShortDesc());
        ItemImage itemImage = master.getItemLanguage().getImage();
        if (itemImage != null) {
          bean.setImageId(itemImage.getImageId().toString());
        }
            if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()){
              for (ItemLanguage itemLanguage : master.getItemLanguages()) {
                if (itemLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                  if (itemLanguage.getItemShortDesc() != null) {
                    bean.setItemShortDesc(itemLanguage.getItemShortDesc());
                  }
                  if (itemLanguage.getItemImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
                    bean.setImageId(itemLanguage.getImage().getImageId().toString());
                  }
                  break;
                }
              }
            }
           
            Vector<ShoppingCartItemAttributeBean> shoppingCartItemAttributes = new Vector<ShoppingCartItemAttributeBean>();
            Iterator<?> itemAttributeInfoIterator = shoppingCartItem.getItemAttributeInfos().iterator();
            while (itemAttributeInfoIterator.hasNext()) {
              ItemAttributeInfo itemAttributeInfo = (ItemAttributeInfo) itemAttributeInfoIterator.next();
              ShoppingCartItemAttributeBean attributeBean = new ShoppingCartItemAttributeBean();
             
              ItemAttributeDetail itemAttributeDetail = (ItemAttributeDetail) em.find(ItemAttributeDetail.class, itemAttributeInfo.getItemAttribDetailId());
              CustomAttribute customAttribute = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_INPUT) {
                continue;
              }
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_SELECT_DROPDOWN) {
                continue;
              }
             
              attributeBean.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
              if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
                for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                    if (language.getCustomAttribDesc() != null) {
                      attributeBean.setCustomAttribDesc(language.getCustomAttribDesc());
                    }
                      break;
                  }
                }
              }
             
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) {
                attributeBean.setCustomAttribValue(itemAttributeInfo.getItemAttribDetailValue());
              }
              else {
                CustomAttributeOption customAttribOption = CustomAttributeOptionDAO.load(site.getSiteId(), itemAttributeInfo.getCustomAttribOptionId());
                attributeBean.setCustomAttribValue(customAttribOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
                if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
                  for (CustomAttributeOptionLanguage language : customAttribOption.getCustomAttributeOptionLanguages()) {
                    if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                      if (language.getCustomAttribValue() != null) {
                        attributeBean.setCustomAttribValue(language.getCustomAttribValue());
                      }
                      break;
                    }
                  }
                }
              }
              shoppingCartItemAttributes.add(attributeBean);
            }
            bean.setShoppingCartItemAttributes(shoppingCartItemAttributes);
        vector.add(bean);
      }
      form.setShoppingCartItemInfos(vector);
     
      Vector<ShoppingCartCouponBean> couponVector = new Vector<ShoppingCartCouponBean>();
      iterator = shoppingCart.getShoppingCartCoupons().iterator();
      while (iterator.hasNext()) {
        ShoppingCartCoupon shoppingCartCoupon = (ShoppingCartCoupon) iterator.next();
        Coupon coupon = shoppingCartCoupon.getCoupon();
        ShoppingCartCouponBean bean = new ShoppingCartCouponBean();
        bean.setCouponId(Format.getLong(coupon.getCouponId()));
        bean.setCouponCode(coupon.getCouponCode());
        bean.setCouponName(coupon.getCouponLanguage().getCouponName());
        if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
          for (CouponLanguage language : coupon.getCouponLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getCouponName() != null) {
                bean.setCouponName(language.getCouponName());
              }
              break;
            }
          }
        }
        bean.setCouponAmount(formatter.formatCurrency(shoppingCartCoupon.getCouponAmount()));
        couponVector.add(bean);
      }
      form.setShoppingCartCouponInfos(couponVector);
     
      ItemTax taxes[] = shoppingCart.getTaxes();
       Vector<ShoppingCartTaxInfo> taxVector = new Vector<ShoppingCartTaxInfo>();
      if (taxes != null) {
        for (int i = 0; i < taxes.length; i++) {
          ShoppingCartTaxInfo taxInfo = new ShoppingCartTaxInfo();
          Tax tax = taxes[i].getTax();
          taxInfo.setTaxName(tax.getTaxLanguage().getTaxName());
          if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
            for (TaxLanguage language : tax.getTaxLanguages()) {
              if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                if (language.getTaxName() != null) {
                  taxInfo.setTaxName(language.getTaxName());
                }
                break;
              }
            }
          }
          taxInfo.setTaxAmount(formatter.formatCurrency(taxes[i].getTaxAmount()));
          taxVector.add(taxInfo);
        }
      }
      Collections.sort(taxVector);
      form.setShoppingCartTaxInfos(taxVector);
     
      form.setPriceTotal(formatter.formatCurrency(shoppingCart.getShoppingCartSubTotal()));
      form.setTaxTotal(formatter.formatCurrency(shoppingCart.getTaxTotal()));
      form.setShippingTotal(formatter.formatCurrency(shoppingCart.getShippingTotal()));
      form.setShippingDiscountTotal(formatter.formatCurrency(shoppingCart.getShippingDiscountTotal()));
      form.setShippingOrderTotal(formatter.formatCurrency(shoppingCart.getShippingOrderTotal()));
      form.setOrderTotal(formatter.formatCurrency(shoppingCart.getOrderTotal()));
     
      Vector<?> shippingMethodVector = shoppingCart.getShippingMethods();
      Vector<LabelValueBean> smVector = new Vector<LabelValueBean>();
      iterator = shippingMethodVector.iterator();
      while (iterator.hasNext()) {
        ShippingMethod shippingMethod = (ShippingMethod) iterator.next();
        LabelValueBean bean = new LabelValueBean();
        bean.setLabel(shippingMethod.getShippingMethodLanguage().getShippingMethodName());
        bean.setValue(shippingMethod.getShippingMethodId().toString());
            if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
          for (ShippingMethodLanguage language : shippingMethod.getShippingMethodLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getShippingMethodName() != null) {
                bean.setLabel(language.getShippingMethodName());
              }
              break;
            }
          }
            }
        smVector.add(bean);
      }
      LabelValueBean shippingMethods[] = new LabelValueBean[smVector.size()];
      smVector.copyInto(shippingMethods);
      form.setShippingMethods(shippingMethods);
     
      SiteDomainLanguage siteDomainLanguage = contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage();
      for (SiteDomainLanguage language : contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguages()) {
        if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
          siteDomainLanguage = language;
          break;
        }
      }
     
      SiteDomainParamBean siteDomainParamBean = SiteDomainDAO.getSiteDomainParamBean(contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage(), siteDomainLanguage);
      form.setShoppingCartMessage(siteDomainParamBean.getCheckoutShoppingCartMessage());
      PaymentEngine paymentEngine = shoppingCart.getPaymentEngine();
      if (paymentEngine != null) {
        form.setPaymentGatewayProvider(paymentEngine.getClass().getSimpleName());
      }
      form.setCashPaymentOrder(shoppingCart.isCashPaymentOrder());
      form.setPayPal(shoppingCart.isPayPal());
      form.setCreditCard(shoppingCart.isCreditCard());
      form.setCashPayment(shoppingCart.isCashPayment());
     
      boolean includeShippingPickUp = false;
      if (siteDomainParamBean.getCheckoutIncludeShippingPickup() != null) {
        includeShippingPickUp = siteDomainParamBean.getCheckoutIncludeShippingPickup().equals(String.valueOf(Constants.VALUE_YES));
      }
      form.setIncludeShippingPickUp(includeShippingPickUp);
      shoppingCart.setIncludeShippingPickUp(includeShippingPickUp);
     
        form.setShippingValid(shoppingCart.isShippingValid());
        if (!shoppingCart.isShippingValid()) {
          messages.add("shippingLocation", new ActionMessage("content.error.shippingLocation.unsupported"));
          form.setAllowShippingQuote(false);
          if (siteDomainParamBean.getCheckoutAllowsShippingQuote() != null && siteDomainParamBean.getCheckoutAllowsShippingQuote().equals(String.valueOf(Constants.VALUE_YES))) {
            form.setAllowShippingQuote(true);
          }
        }
     
      ContentApi contentApi = new ContentApi(request);
     
      Vector<ItemInfo> crossSellItems = new Vector<ItemInfo>();
      iterator = shoppingCart.getShoppingCartItems().iterator();
      while (iterator.hasNext()) {
        ShoppingCartItem shoppingCartItem = (ShoppingCartItem) iterator.next();
        Item item = shoppingCartItem.getItem();
        if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
          item = item.getItemSkuParent();
        }
        Iterator<?> itemsCrossSell = item.getItemsCrossSell().iterator();
        while (itemsCrossSell.hasNext()) {
View Full Code Here

TOP

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

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.