protected void saveLatestOrder(ActionRequest actionRequest) throws Exception {

    ShoppingCart cart = ShoppingUtil.getCart(actionRequest);

    ShoppingOrder order = ShoppingOrderLocalServiceUtil.saveLatestOrder(cart);

    actionRequest.setAttribute(WebKeys.SHOPPING_ORDER, order);
  }
  protected void getLatestOrder(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    ShoppingOrder order =
        ShoppingOrderLocalServiceUtil.getLatestOrder(
            themeDisplay.getUserId(), themeDisplay.getScopeGroupId());

    actionRequest.setAttribute(WebKeys.SHOPPING_ORDER, order);
  }
示例#3
0
  protected void forwardCheckout(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    ShoppingCart cart = ShoppingUtil.getCart(actionRequest);

    ShoppingOrder order = (ShoppingOrder) actionRequest.getAttribute(WebKeys.SHOPPING_ORDER);

    ShoppingPreferences preferences =
        ShoppingPreferences.getInstance(
            themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());

    String returnURL =
        ShoppingUtil.getPayPalReturnURL(
            ((ActionResponseImpl) actionResponse).createActionURL(), order);
    String notifyURL = ShoppingUtil.getPayPalNotifyURL(themeDisplay);

    if (preferences.usePayPal()) {
      double total =
          ShoppingUtil.calculateTotal(
              cart.getItems(),
              order.getBillingState(),
              cart.getCoupon(),
              cart.getAltShipping(),
              cart.isInsure());

      String redirectURL =
          ShoppingUtil.getPayPalRedirectURL(preferences, order, total, returnURL, notifyURL);

      actionResponse.sendRedirect(redirectURL);
    } else {
      ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

      ShoppingOrderLocalServiceUtil.sendEmail(order, "confirmation", serviceContext);

      actionResponse.sendRedirect(returnURL);
    }
  }
  protected void updateLatestOrder(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String billingFirstName = ParamUtil.getString(actionRequest, "billingFirstName");
    String billingLastName = ParamUtil.getString(actionRequest, "billingLastName");
    String billingEmailAddress = ParamUtil.getString(actionRequest, "billingEmailAddress");
    String billingCompany = ParamUtil.getString(actionRequest, "billingCompany");
    String billingStreet = ParamUtil.getString(actionRequest, "billingStreet");
    String billingCity = ParamUtil.getString(actionRequest, "billingCity");

    String billingStateSel = ParamUtil.getString(actionRequest, "billingStateSel");
    String billingState = billingStateSel;

    if (Validator.isNull(billingStateSel)) {
      billingState = ParamUtil.getString(actionRequest, "billingState");
    }

    String billingZip = ParamUtil.getString(actionRequest, "billingZip");
    String billingCountry = ParamUtil.getString(actionRequest, "billingCountry");
    String billingPhone = ParamUtil.getString(actionRequest, "billingPhone");

    boolean shipToBilling = ParamUtil.getBoolean(actionRequest, "shipToBilling");
    String shippingFirstName = ParamUtil.getString(actionRequest, "shippingFirstName");
    String shippingLastName = ParamUtil.getString(actionRequest, "shippingLastName");
    String shippingEmailAddress = ParamUtil.getString(actionRequest, "shippingEmailAddress");
    String shippingCompany = ParamUtil.getString(actionRequest, "shippingCompany");
    String shippingStreet = ParamUtil.getString(actionRequest, "shippingStreet");
    String shippingCity = ParamUtil.getString(actionRequest, "shippingCity");

    String shippingStateSel = ParamUtil.getString(actionRequest, "shippingStateSel");
    String shippingState = shippingStateSel;

    if (Validator.isNull(shippingStateSel)) {
      shippingState = ParamUtil.getString(actionRequest, "shippingState");
    }

    String shippingZip = ParamUtil.getString(actionRequest, "shippingZip");
    String shippingCountry = ParamUtil.getString(actionRequest, "shippingCountry");
    String shippingPhone = ParamUtil.getString(actionRequest, "shippingPhone");

    String ccName = ParamUtil.getString(actionRequest, "ccName");
    String ccType = ParamUtil.getString(actionRequest, "ccType");
    String ccNumber = ParamUtil.getString(actionRequest, "ccNumber");
    int ccExpMonth = ParamUtil.getInteger(actionRequest, "ccExpMonth");
    int ccExpYear = ParamUtil.getInteger(actionRequest, "ccExpYear");
    String ccVerNumber = ParamUtil.getString(actionRequest, "ccVerNumber");

    String comments = ParamUtil.getString(actionRequest, "comments");

    ShoppingOrder order =
        ShoppingOrderLocalServiceUtil.updateLatestOrder(
            themeDisplay.getUserId(),
            themeDisplay.getScopeGroupId(),
            billingFirstName,
            billingLastName,
            billingEmailAddress,
            billingCompany,
            billingStreet,
            billingCity,
            billingState,
            billingZip,
            billingCountry,
            billingPhone,
            shipToBilling,
            shippingFirstName,
            shippingLastName,
            shippingEmailAddress,
            shippingCompany,
            shippingStreet,
            shippingCity,
            shippingState,
            shippingZip,
            shippingCountry,
            shippingPhone,
            ccName,
            ccType,
            ccNumber,
            ccExpMonth,
            ccExpYear,
            ccVerNumber,
            comments);

    actionRequest.setAttribute(WebKeys.SHOPPING_ORDER, order);
  }