private void LoadUpgradeSku()
        {
            int upgradeSkuId = 0;
            int skuId        = 0;

            foreach (Sku sku in CartContext.CartInfo.CartItems)
            {
                skuId = sku.SkuId;
                //if (sku.SkuId == 112)
                //    upgradeSkuId = 114;
                if (sku.SkuId == 111)
                {
                    upgradeSkuId = 114;
                }
                break;
            }
            if (upgradeSkuId > 0)
            {
                SkuManager skuManager = new SkuManager();
                Sku        sku        = skuManager.GetSkuByID(skuId);
                sku.LoadAttributeValues();
                if (sku.ContainsAttribute("upgradetext") && sku.AttributeValues["upgradetext"] != null)
                {
                    lblUpgrade.Text = sku.AttributeValues["upgradetext"].Value;
                }

                imgUpgrade.CommandArgument = upgradeSkuId.ToString();
                pnlUpgrade.Visible         = true;
            }
        }
Пример #2
0
        public void BindAll()
        {
            SkuManager skuMgr = new SkuManager();

            rptSkuItem.DataSource = skuMgr.GetAllSkus();
            rptSkuItem.DataBind();

            rptRushSkuItem.DataSource = skuMgr.GetAllSkus();
            rptRushSkuItem.DataBind();

            rptItems.DataSource = ShippingDAL.GetShippingOrderValue(ShippingOptionType.TotalAmount, false, DefaultSitePrefereceId);
            rptItems.DataBind();

            rptRushOrderTotal.DataSource = ShippingDAL.GetShippingOrderValue(ShippingOptionType.TotalAmount, true, DefaultSitePrefereceId);
            rptItems.DataBind();
            rptRushOrderTotal.DataBind();

            rptOrderWeight.DataSource = ShippingDAL.GetShippingOrderValue(ShippingOptionType.Weight, false, DefaultSitePrefereceId);
            rptItems.DataBind();
            rptOrderWeight.DataBind();

            rptRushOrderWeight.DataSource = ShippingDAL.GetShippingOrderValue(ShippingOptionType.Weight, true, DefaultSitePrefereceId);
            rptItems.DataBind();
            rptRushOrderWeight.DataBind();

            rptShippingCharges.DataSource = ShippingDAL.GetShippingChargesByPref(DefaultSitePrefereceId);
            rptShippingCharges.DataBind();
        }
Пример #3
0
        protected void rptShoppingCart_OnItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "delete":
            {
                SkuManager skuManager  = new SkuManager();
                int        skuToRemove = Convert.ToInt32(e.CommandArgument);
                Sku        s           = skuManager.GetSkuByID(skuToRemove);
                s.LoadAttributeValues();
                CartContext.CartInfo.UpdateSku(skuToRemove);
                BindControls();
                if (UpdateCart != null)
                {
                    UpdateCart(sender, e);
                }

                //if (s.GetAttributeValue<string>("title",string.Empty).ToLower().Equals("tpillow"))
                //{
                //    ibTPillow.Enabled = true;
                //    ibTPillow.ImageUrl = "//d39hwjxo88pg52.cloudfront.net/wonderflex/images/btn_addtocart.png";
                //}
                //if (s.GetAttributeValue<string>("title", string.Empty).ToLower().Equals("additional"))
                //{
                //    ibAdditioanl.Enabled = true;
                //    ibAdditioanl.ImageUrl = "//d39hwjxo88pg52.cloudfront.net/wonderflex/images/btn_addtocart.png";
                //}
            }
            break;

            default:
                break;
            }
        }
Пример #4
0
        private static IOrder CreateTestClass()
        {
            var skus = new SkuManager();

            // Add price-only sku (use cases 1 & 2)
            skus.AddSku(SKU_ONE, PRICE_ONE);

            // Add markdown sku (use case 3)
            skus.AddSku(SKU_TWO, PRICE_TWO);
            skus.AddMarkdown(SKU_TWO, MARKDOWN_TWO);

            // Add BOGO sku with limit (use case 4, 6)
            skus.AddSku(SKU_THREE, PRICE_THREE);
            skus.AddSpecial(SKU_THREE, 3, SPECIAL_BOGO_FREE, true, false, 8);

            // Add M for N sku (use case 5)
            skus.AddSku(SKU_FOUR, PRICE_FOUR);
            skus.AddSpecial(SKU_FOUR, 2, PRICE_TWO, false, false);

            // Add M for N off equal or lesser value (use case 8)
            skus.AddSku(SKU_FIVE, PRICE_FIVE);
            skus.AddSpecial(SKU_FIVE, .1, SPECIAL_BOGO_HALF, true, true);

            return(new Order {
                Skus = skus
            });
        }
        public String ImageURL(int skuid)
        {
            string imageUrl = "";
            Sku    s        = new SkuManager().GetSkuByID(skuid);

            imageUrl = s.ImagePath;
            return(imageUrl);
        }
Пример #6
0
        public string GetSkuCode(int skuId, int countryId, string versionName)
        {
            Sku st = new SkuManager().GetSkuByID(skuId);

            st.LoadAttributeValues();
            bool isVersionE2 = versionName.ToUpper().Contains("E2") || versionName.ToUpper().Contains("GET");

            if (!isVersionE2)
            {
                if (countryId == 46)
                {
                    if (st.GetAttributeValue <string>("skucodeca", string.Empty) != string.Empty)
                    {
                        return(st.GetAttributeValue <string>("skucodeca", string.Empty));
                    }
                    else
                    {
                        return(st.SkuCode);
                    }
                }
                else
                {
                    return(st.SkuCode);
                }
            }
            else
            {
                if (countryId == 46)
                {
                    if (st.GetAttributeValue <string>("E2_SKUCODECA", string.Empty) != string.Empty)
                    {
                        return(st.GetAttributeValue <string>("E2_SKUCODECA", string.Empty));
                    }
                    else if (st.GetAttributeValue <string>("skucodeca", string.Empty) != string.Empty)
                    {
                        return(st.GetAttributeValue <string>("skucodeca", string.Empty));
                    }
                    else
                    {
                        return(st.SkuCode);
                    }
                }
                else
                {
                    if (st.GetAttributeValue <string>("E2_SKUCODE", string.Empty) != string.Empty)
                    {
                        return(st.GetAttributeValue <string>("E2_SKUCODE", string.Empty));
                    }
                    else
                    {
                        return(st.SkuCode);
                    }
                }
            }

            //return "";
        }
Пример #7
0
        protected void rptShoppingCart_OnItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "delete":
            {
                int skuToRemove = Convert.ToInt32(e.CommandArgument);
                CartContext.CartInfo.UpdateSku(skuToRemove);
                Sku sku = new SkuManager().GetSkuByID(skuToRemove);
                sku.LoadAttributeValues();
                var removeSkus = sku.GetAttributeValue <string>("removeSku", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string removeSku in removeSkus)
                {
                    if (CartContext.CartInfo.SkuExists(int.Parse(removeSku)))
                    {
                        CartContext.CartInfo.UpdateSku(int.Parse(removeSku));
                        Sku skuRemove = new SkuManager().GetSkuByID(int.Parse(removeSku));
                        skuRemove.LoadAttributeValues();
                        var replaceSkus = skuRemove.GetAttributeValue <string>("replaceSku", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string replaceSku in replaceSkus)
                        {
                            OrderHelper.ChangeCart(replaceSku);
                        }
                    }
                }
                bool flag = false;
                foreach (Sku sku1 in ClientOrderData.CartInfo.CartItems)
                {
                    if ((sku1.SkuId >= 138 && sku1.SkuId <= 152) || sku1.SkuId == 161)         // g2 individual products
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    SiteBasePage.SetCatalogShipping();
                }
                BindControls();
                if (UpdateCart != null)
                {
                    UpdateCart(sender, e);
                }
                Response.Redirect(Request.RawUrl);
            }
            break;

            default:
                break;
            }
        }
Пример #8
0
        //private decimal GetSkuTaxCost(CSBusiness.CustomerManagement.Address shippingAddress, Sku sku)
        //{
        //    decimal taxToReturn = 0;
        //    SitePreference list = CSFactory.GetCartPrefrence();
        //    decimal taxableAmount = sku.FullPrice;

        //    //If this returns a value, it means country has states and we need to
        //    //find tax for states
        //    if (shippingAddress.CountryId > 0)
        //    {
        //        //CodeReview By Sri on 09/15: Need to change TaxRegionCache Object
        //        TaxRegion countryRegion = null, stateRegion = null, zipRegion = null;

        //        //Comments on 11/2: pulling data from Cache object
        //        TaxregionCache cache = new TaxregionCache(HttpContext.Current);
        //        List<TaxRegion> taxRegions = (List<TaxRegion>)cache.Value;

        //        countryRegion = taxRegions.FirstOrDefault(t => t.CountryId == shippingAddress.CountryId && t.StateId == 0 && string.IsNullOrEmpty(t.ZipCode));
        //        stateRegion = taxRegions.FirstOrDefault(t => t.CountryId == shippingAddress.CountryId && t.StateId == shippingAddress.StateProvinceId && string.IsNullOrEmpty(t.ZipCode));
        //        zipRegion = taxRegions.FirstOrDefault(t => t.CountryId == shippingAddress.CountryId && t.StateId == shippingAddress.StateProvinceId
        //            && t.ZipCode == shippingAddress.ZipPostalCode);

        //        //Tax regions are always returned by country
        //        //taxRegions = CSFactory.GetTaxByCountry(cart.ShippingAddress.CountryId);
        //        if (zipRegion != null)
        //        {
        //            taxToReturn = taxableAmount * zipRegion.Value / 100;
        //        }
        //        else if (stateRegion != null)
        //        {
        //            taxToReturn = taxableAmount * stateRegion.Value / 100;
        //        }
        //        else if (countryRegion != null)
        //        {
        //            taxToReturn = taxableAmount * countryRegion.Value / 100;
        //        }
        //    }
        //    return Math.Round(taxToReturn, 2);

        //}
        //private bool IsContinental(string state)
        //{
        //    if (stateCode.Contains("AK")
        //        || stateCode.Contains("HI")
        //        || stateCode.Contains("PR")
        //        || stateCode.Contains("GU"))
        //        return false;
        //    if (state.Contains("Alaska")
        //        || state.Contains("Hawaii")
        //        || state.Contains("Puerto Rico")
        //        || state.Contains("Guam"))
        //        return false;
        //    return true;
        //}
        private Sku GetShippingSku(Order orderItem)
        {
            SkuManager skuManager = new SkuManager();

            foreach (Sku sku in orderItem.SkuItems)
            {
                if (skuManager.GetSkuByID(sku.SkuId).CategoryId == 14)
                {
                    //if (!IsContinental(orderItem.CustomerInfo.ShippingAddress.StateProvinceName))
                    //    sku.SkuCode = sku.SkuCode + "1";
                    return(sku);
                }
            }
            return(null);
        }
Пример #9
0
        protected void rbClassic_CheckedChanged(object sender, EventArgs e)
        {
            int skuId = 0;

            if (rbClassic.Checked)
            {
                skuId = 110;
            }
            if (rbComplete.Checked)
            {
                skuId = 111;
            }

            SkuManager skuManager = new SkuManager();

            LoadOfferTerms(skuManager.GetSkuByID(skuId));
        }
Пример #10
0
        public string GetSkuCode(int skuId, int countryId)
        {
            Sku st = new SkuManager().GetSkuByID(skuId);

            st.LoadAttributeValues();
            if (countryId == 46)
            {
                if (st.GetAttributeValue <string>("skucodeca", string.Empty) != string.Empty)
                {
                    return(st.GetAttributeValue <string>("skucodeca", string.Empty));
                }
                else
                {
                    return(st.SkuCode);
                }
            }
            else
            {
                return(st.SkuCode);
            }
            //return "";
        }
Пример #11
0
        private void LoadTemplate(int templateIndex)
        {
            if (templateIndex < AllTemplates.Count)
            {
                //We're making a separate call to database just to get
                //full template object, ideally we should merge these two calls
                int         currentTemplateId = AllTemplates[templateIndex];
                PathManager pathManager       = new PathManager();
                Template    currentTemplate   = pathManager.GetTemplate(currentTemplateId);

                if (currentTemplate.UriLabel != null)
                {
                    Session["PostSaleLabelName"] = currentTemplate.UriLabel;
                }
                else
                {
                    Session["PostSaleLabelName"] = "";
                }
                if (currentTemplate.CanUseTemplate(CartContext))
                {
                    //decimal orderTotal = 0;
                    //decimal neworderTotal = 0;
                    //decimal shippingandhandling = 0;
                    //Order orderItem = new OrderManager().GetBatchProcessOrders(CartContext.OrderId);
                    //shippingandhandling = orderItem.ShippingCost;
                    //foreach (Sku s in orderItem.SkuItems)
                    //{
                    //    orderTotal += s.InitialPrice;
                    //    s.LoadAttributeValues();
                    //    try
                    //    {
                    //        if (s.AttributeValues["relatedonepaysku"] != null && !s.AttributeValues["relatedonepaysku"].Value.Equals(""))
                    //        {
                    //            int skuId = Convert.ToInt32(s.AttributeValues["relatedonepaysku"].Value);
                    //            Sku st = new SkuManager().GetSkuByID(skuId);
                    //            //st.SkuId = skuId;

                    //            st.LoadAttributeValues();
                    //            neworderTotal += st.InitialPrice;
                    //        }
                    //    }
                    //    catch
                    //    {


                    //    }
                    //}
                    decimal orderTotal          = 0;
                    decimal neworderTotal       = 0;
                    decimal shippingandhandling = 0;
                    string  templateBody        = currentTemplate.Body;

                    if (templateBody.Contains("<input type=\"hidden\" name=\"onepay\" value=\"onepay\" id=\"onepay\" />"))
                    {
                        Order orderItem = new OrderManager().GetBatchProcessOrders(CartContext.OrderId);
                        shippingandhandling = orderItem.ShippingCost;
                        foreach (Sku s in orderItem.SkuItems)
                        {
                            orderTotal += s.InitialPrice;
                            s.LoadAttributeValues();
                            try
                            {
                                if (s.AttributeValues["relatedonepaysku"] != null && !s.AttributeValues["relatedonepaysku"].Value.Equals(""))
                                {
                                    int skuId = Convert.ToInt32(s.AttributeValues["relatedonepaysku"].Value);
                                    Sku st    = new SkuManager().GetSkuByID(skuId);
                                    //st.SkuId = skuId;

                                    st.LoadAttributeValues();
                                    neworderTotal += st.InitialPrice;
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    templateBody = UpdateTemplateForGiftWrapItems(templateBody);
                    StringBuilder sb = new StringBuilder();
                    sb.Append(templateBody);

                    //templateBody.Replace('{upsellTotal}', Math.Round(neworderTotal, 2).ToString());
                    sb.Replace("{upsellTotal}", Math.Round(neworderTotal, 2).ToString());
                    sb.Replace("{upsellshipping}", Math.Round(shippingandhandling, 2).ToString());
                    sb.Replace("{upsellsave}", Math.Round(shippingandhandling + 14.95m, 2).ToString());
                    templateBody = sb.ToString();
                    templateBody = BindLinks(templateBody);
                    templateBody = BindValidators(templateBody);
                    BindContainers(templateBody);

                    string script = string.Format("<script type=\"text/javascript\">\r\n{0}\r\n</script>", currentTemplate.Script);

                    //Tags contain some template related configuration information
                    var templateTagsXml = XElement.Parse("<Display>" + currentTemplate.Tag + "</Display>");

                    templateBody = InsertData(templateTagsXml, templateBody);

                    // write template html to page
                    mainContainer.InnerHtml = string.Format("{0}\r\n{1}", script, templateBody);
                }
                else
                {
                    GoToNextTemplate();
                }
            }
        }
Пример #12
0
        protected void btnAction_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Save")
            {
                if (Page.IsValid)
                {
                    Sku sku = new SkuManager().GetSkuItem();
                    sku.SkuId        = SkuId;
                    sku.Title        = txtTitle.Text;
                    sku.SkuCode      = txtSkuCode.Text;
                    sku.CategoryId   = Convert.ToInt32(ddlCategory.SelectedValue);
                    sku.OfferCode    = txtOfferCode.Text;
                    sku.FullPrice    = Convert.ToDecimal(txtfullprice.Text);
                    sku.InitialPrice = Convert.ToDecimal(txtinitialprice.Text);
                    sku.ImagePath    = txtImagePath.Text;
                    if (txtStock.Text.Length > 0)
                    {
                        sku.StockQty = Convert.ToInt32(txtStock.Text);
                    }
                    else
                    {
                        sku.StockQty = 0;
                    }
                    sku.IsAvailable = cbAvailable.Checked;
                    if (rbListTaxable.SelectedIndex == 0)
                    {
                        sku.IsTaxable = true;
                    }
                    else
                    {
                        sku.IsTaxable = false;
                    }

                    if (pnlTaxableAmount.Visible)
                    {
                        sku.TaxableFullAmount = Convert.ToDecimal(txtTaxAmount.Text);
                    }
                    else
                    {
                        sku.TaxableFullAmount = 0;
                    }
                    if (txtWeight.Text.Length > 0)
                    {
                        sku.Weight = Convert.ToDecimal(txtWeight.Text);
                    }
                    else
                    {
                        sku.Weight = 0;
                    }
                    sku.ShortDescription = ftbShortDesc.Content;
                    sku.LongDescription  = ftbLongDesc.Content;
                    sku.EmailDescription = ftbEmailDesc.Content;
                    sku.CreateDate       = DateTime.Now;
                    sku.ModifyDate       = DateTime.Now;

                    List <string> deleteAttributes;

                    sku.AttributeValues = ucAttributes.GetEnteredAttributeValues(out deleteAttributes);

                    new SkuManager().InsertSku(sku);

                    ucAttributes.SaveDeletedAttributes(sku.ObjectName, sku.ItemId);
                }
                lblSuccess.Visible = true;
                lblCancel.Visible  = false;
            }
            else
            {
                Response.Redirect("skulist.aspx");
            }

            //Response.Redirect("skulist.aspx");
        }
        public void LoadShippingPreference(int PrefId)
        {
            SkuManager skuMgr = new SkuManager();

            rptSkuItem.DataSource = skuMgr.GetAllSkus();
            rptSkuItem.DataBind();

            rptRushSkuItem.DataSource = skuMgr.GetAllSkus();
            rptRushSkuItem.DataBind();

            if (PrefId > 0)
            {
                ShippingPref val = ShippingDAL.GetShippingPref(PrefId);
                txtFlat.Text                 = String.Format("{0:0.##}", val.flatShipping);
                txtRushFlat.Text             = String.Format("{0:0.##}", val.RushShippingCost);
                cbRushShippingOption.Checked = (bool)val.InCludeRushShipping;
                rushShippingSettings.Visible = cbRushShippingOption.Checked;



                rptItems.DataSource = ShippingDAL.GetShippingOrderValue(ShippingOptionType.TotalAmount, false, PrefId);
                rptItems.DataBind();
                rptItems.DataBind();

                rptRushOrderTotal.DataSource = ShippingDAL.GetShippingOrderValue(ShippingOptionType.TotalAmount, true, PrefId);
                rptItems.DataBind();
                rptRushOrderTotal.DataBind();

                rptOrderWeight.DataSource = ShippingDAL.GetShippingOrderValue(ShippingOptionType.Weight, false, PrefId);
                rptItems.DataBind();
                rptOrderWeight.DataBind();

                rptRushOrderWeight.DataSource = ShippingDAL.GetShippingOrderValue(ShippingOptionType.Weight, true, PrefId);
                rptItems.DataBind();
                rptRushOrderWeight.DataBind();


                switch (val.OptionId)
                {
                case (int)ShippingOptionType.TotalAmount:
                    cbOrderSubTotal.Checked = true;
                    pnlOrderVal.Visible     = true;
                    break;

                case (int)ShippingOptionType.Weight:
                    cbOrderWeight.Checked = true;
                    pnlWeight.Visible     = true;
                    break;

                case (int)ShippingOptionType.SkuBased:
                    cbSkuItem.Checked  = true;
                    pnlSkuItem.Visible = true;
                    break;

                case (int)ShippingOptionType.Flat:
                    cbFlat.Checked  = true;
                    pnlFlat.Visible = true;
                    break;

                case (int)ShippingOptionType.SiteLevelPref:
                    cbSitePref.Checked = true;
                    break;
                }

                switch (val.RushOptionId)
                {
                case (int)ShippingOptionType.TotalAmount:
                    cbRushOrderTotal.Checked  = true;
                    pnlRushOrderTotal.Visible = true;
                    break;

                case (int)ShippingOptionType.Weight:
                    cbRushOrderweight.Checked  = true;
                    pnlRushOrderweight.Visible = true;
                    break;

                case (int)ShippingOptionType.SkuBased:
                    cbRushSkuItem.Checked  = true;
                    pnlRushSkuItem.Visible = true;
                    break;

                case (int)ShippingOptionType.Flat:
                    cbRushFlat.Checked  = true;
                    pnlRushFlat.Visible = true;
                    break;

                case (int)ShippingOptionType.SiteLevelPref:
                    cbRushSitePref.Checked = true;
                    break;
                }
            }
        }
Пример #14
0
        public string GetRequest(Order orderItem)
        {
            string Prefix        = config.Attributes["MVISPrefix"].Value.ToUpper();
            string DNIS          = config.Attributes["DNIS"].Value.ToUpper();
            string NoSoliciting  = config.Attributes["NO_SOLICITING"].Value.ToUpper();
            string PaymentType   = config.Attributes["PaymentType"].Value.ToUpper();    // AUTH OR SALE or BLANK
            string PaymentMethod = config.Attributes["PAYMENT_METHOD"].Value.ToUpper(); // CC or CK (Check)
            string EmpNumber     = config.Attributes["EmpNumber"].Value.ToUpper();

            string CustomerNumber       = Prefix + "-" + orderItem.CustomerId; // BillingAddress.AddressId.ToString();
            List <StateProvince> states = StateManager.GetAllStates(0);
            String strXml    = String.Empty;
            string lineItems = String.Empty;

            orderItem.LoadAttributeValues();
            using (StringWriter str = new StringWriter())
            {
                using (XmlTextWriter xml = new XmlTextWriter(str))
                {
                    string sid  = "default";
                    string afid = string.Empty;
                    string cid  = string.Empty;
                    string adid = string.Empty;
                    if (orderItem.CustomFiledInfo != null)
                    {
                        if (orderItem.CustomFiledInfo.Count > 0)
                        {
                            try
                            {
                                if (orderItem.CustomFiledInfo.Find(x => x.FieldName.ToLower() == "afid") != null)
                                {
                                    afid = orderItem.CustomFiledInfo.Find(x => x.FieldName.ToLower() == "afid").FieldValue.ToString();
                                }
                                if (orderItem.CustomFiledInfo.Find(x => x.FieldName.ToLower() == "sid") != null)
                                {
                                    sid = orderItem.CustomFiledInfo.Find(x => x.FieldName.ToLower() == "sid").FieldValue.ToString();
                                }
                                if (orderItem.CustomFiledInfo.Find(x => x.FieldName.ToLower() == "adid") != null)
                                {
                                    adid = orderItem.CustomFiledInfo.Find(x => x.FieldName.ToLower() == "adid").FieldValue.ToString();
                                }
                                if (orderItem.CustomFiledInfo.Find(x => x.FieldName.ToLower() == "cid") != null)
                                {
                                    cid = orderItem.CustomFiledInfo.Find(x => x.FieldName.ToLower() == "cid").FieldValue.ToString();
                                }
                            }
                            catch { }
                        }
                    }

                    sid = orderItem.GetAttributeValue <string>("sid", string.Empty);

                    xml.WriteStartElement("OrderImport");
                    xml.WriteStartElement("Order");
                    xml.WriteElementString("CUSTOMER_NUMBER", CustomerNumber); // Store Billing Address ID as Customer Number
                    xml.WriteElementString("BILL_COMPANY", "");
                    xml.WriteElementString("BILL_FIRST_NAME", orderItem.CustomerInfo.BillingAddress.FirstName.Replace("&amp;", "").Replace(" &", "").Replace("'", ""));
                    xml.WriteElementString("BILL_LAST_NAME", orderItem.CustomerInfo.BillingAddress.LastName.Replace("&amp;", "").Replace("&", "").Replace("'", ""));
                    xml.WriteElementString("BILL_ADDRESS1", orderItem.CustomerInfo.BillingAddress.Address1.Replace("&amp;", "").Replace("&", "").Replace("'", ""));
                    xml.WriteElementString("BILL_ADDRESS2", orderItem.CustomerInfo.BillingAddress.Address2.Replace("&amp;", "").Replace("&", "").Replace("'", ""));
                    xml.WriteElementString("BILL_CITY", orderItem.CustomerInfo.BillingAddress.City.Replace("&amp;", "").Replace("&", "").Replace("'", ""));
                    xml.WriteElementString("CUSTOM_2", sid);
                    xml.WriteElementString("CUSTOM_1", DynamicSidDAL.GetDynamicSidData("ProjectCode", sid, orderItem.OrderId));
                    StateProvince itemBillingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.BillingAddress.StateProvinceId));
                    if (itemBillingStateProvince != null)
                    {
                        xml.WriteElementString("BILL_STATE", itemBillingStateProvince.Abbreviation);
                    }
                    else
                    {
                        xml.WriteElementString("BILL_STATE", string.Empty);
                    }

                    xml.WriteElementString("BILL_ZIPCODE", orderItem.CustomerInfo.BillingAddress.ZipPostalCode);
                    if (orderItem.CustomerInfo.BillingAddress.CountryId == 231)
                    {
                        xml.WriteElementString("COUNTRY", "USA");
                    }
                    else if (orderItem.CustomerInfo.BillingAddress.CountryId == 46)
                    {
                        xml.WriteElementString("COUNTRY", "CAN");
                    }
                    xml.WriteElementString("BILL_PHONE_NUMBER", orderItem.CustomerInfo.BillingAddress.PhoneNumber);
                    xml.WriteElementString("BILL_PHONE_2", "");
                    xml.WriteElementString("EMAIL", orderItem.Email);
                    xml.WriteElementString("NO_SOLICITING", NoSoliciting);

                    xml.WriteElementString("SHIP_TO_COMPANY", "");
                    xml.WriteElementString("SHIP_TO_FIRST_NAME", orderItem.CustomerInfo.ShippingAddress.FirstName.Replace("&amp;", "").Replace("&", "").Replace("'", ""));
                    xml.WriteElementString("SHIP_TO_LAST_NAME", orderItem.CustomerInfo.ShippingAddress.LastName.Replace("&amp;", "").Replace("&", "").Replace("'", ""));
                    xml.WriteElementString("SHIP_TO_ADDRESS1", orderItem.CustomerInfo.ShippingAddress.Address1.Replace("&amp;", "").Replace("&", "").Replace("'", ""));
                    xml.WriteElementString("SHIP_TO_ADDRESS2", orderItem.CustomerInfo.ShippingAddress.Address2.Replace("&amp;", "").Replace("&", "").Replace("'", ""));
                    xml.WriteElementString("SHIP_TO_CITY", orderItem.CustomerInfo.ShippingAddress.City.Replace("&amp;", "").Replace("&", "").Replace("'", ""));
                    StateProvince itemShippingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.ShippingAddress.StateProvinceId));
                    if (itemShippingStateProvince != null)
                    {
                        xml.WriteElementString("SHIP_TO_STATE", itemShippingStateProvince.Abbreviation);
                    }
                    else
                    {
                        xml.WriteElementString("SHIP_TO_STATE", string.Empty);
                    }
                    xml.WriteElementString("SHIP_TO_ZIPCODE", orderItem.CustomerInfo.ShippingAddress.ZipPostalCode);
                    if (orderItem.CustomerInfo.ShippingAddress.CountryId == 231)
                    {
                        xml.WriteElementString("SCOUNTRY", "USA");
                    }
                    else if (orderItem.CustomerInfo.ShippingAddress.CountryId == 46)
                    {
                        xml.WriteElementString("SCOUNTRY", "CAN");
                    }
                    xml.WriteElementString("SHIP_TO_PHONE", orderItem.CustomerInfo.BillingAddress.PhoneNumber);
                    xml.WriteElementString("SHIP_TO_PHONE2", "");

                    xml.WriteElementString("ORDER_DATE", orderItem.CreatedDate.ToString("MM/dd/yy"));
                    xml.WriteElementString("ORDER_NUMBER", Prefix + orderItem.OrderId.ToString());
                    xml.WriteElementString("DNIS", DNIS);
                    xml.WriteElementString("EMP_NUMBER", EmpNumber);
                    if (!string.IsNullOrEmpty(orderItem.CreditInfo.TransactionCode))
                    {
                        xml.WriteElementString("PAYMENT_TYPE", PaymentType);  // AUTH or SALE or Blank
                        xml.WriteElementString("AMOUNT_ALREADY_PAID", (orderItem.Total).ToString("N2"));
                        if (orderItem.CreditInfo.CreditCardNumber.Equals("4000000000000002") &&
                            string.IsNullOrEmpty(orderItem.CreditInfo.TransactionCode))
                        {
                            xml.WriteElementString("MERCHANT_TRANSACTION_ID", "Test");
                        }
                        else
                        {
                            xml.WriteElementString("MERCHANT_TRANSACTION_ID", orderItem.CreditInfo.TransactionCode);
                        }
                    }
                    xml.WriteElementString("PAYMENT_METHOD", PaymentMethod); // "CC" for credit card or "CK" for check/check by phone
                    xml.WriteElementString("CC_TYPE", GetCCType(orderItem.CreditInfo.CreditCardName));
                    xml.WriteElementString("CC_NUMBER", orderItem.CreditInfo.CreditCardNumber);
                    xml.WriteElementString("EXP_DATE", orderItem.CreditInfo.CreditCardExpired.ToString("MM/yy"));
                    xml.WriteElementString("CVV_CODE", orderItem.CreditInfo.CreditCardCSC);

                    xml.WriteElementString("SHIPPING_METHOD", "REG");
                    xml.WriteElementString("SHIPPING_CARRIER", "");
                    // We have both Trial as well as One Pay “In the case set Use prices and use shipping to "N."
                    string useShipping = config.Attributes["useShipping"].Value.ToUpper();
                    string usePrices   = config.Attributes["usePrices"].Value.ToUpper();
                    string useTaxes    = config.Attributes["useTaxes"].Value.ToUpper();

                    xml.WriteElementString("USE_SHIPPING", useShipping);
                    xml.WriteElementString("SHIPPING", Math.Round(orderItem.ShippingCost + orderItem.AdditionalShippingCharge, 2).ToString("N2"));
                    xml.WriteElementString("ORDER_STATE_SALES_TAX", Math.Round(orderItem.Tax, 2).ToString("N2"));
                    xml.WriteElementString("USE_PRICES", usePrices);
                    xml.WriteElementString("USE_TAXES", useTaxes);
                    xml.WriteElementString("ORDER_SUBTOTAL", Math.Round(orderItem.FullPriceSubTotal - orderItem.DiscountAmount, 2).ToString("N2"));
                    xml.WriteElementString("ORDER_TOTAL", Math.Round(orderItem.FullPriceSubTotal + orderItem.ShippingCost + orderItem.AdditionalShippingCharge + orderItem.Tax - orderItem.DiscountAmount, 2).ToString("N2"));


                    int        count            = 1;
                    SkuManager skuManager       = new SkuManager();
                    string     fieldnamePRODUCT = "PRODUCT";
                    // string fieldnameDESCRIPTION = "DESCRIPTION" + count.ToString();
                    string fieldnameQUANTITY    = "QUANTITY";
                    string fieldnamePRICE       = "PRICE";
                    string fieldnameDISCOUNT    = "DISCOUNT";
                    string fieldnameCOUPON_CODE = "COUPON_CODE";
                    string fieldnameTAXRATE     = "TAX_RATE";
                    string fieldnamePAIDPRICE   = "PAID_PRICE_PROD";
                    string fieldnameSHIPPING    = "SHIPPING";
                    //PAID_PRICE
                    Order orderCouponInfo = CSResolve.Resolve <IOrderService>().GetOrderDetails(orderItem.OrderId, true);
                    foreach (Sku Item in orderItem.SkuItems)
                    {
                        Sku sku = skuManager.GetSkuByID(Item.SkuId);
                        sku.LoadAttributeValues();
                        if (!sku.GetAttributeValue <bool>("FreeSku", false))
                        {
                            string counter = zeropad(count.ToString(), 2);
                            fieldnamePRODUCT     = "PRODUCT" + counter;
                            fieldnameQUANTITY    = "QUANTITY" + counter;
                            fieldnamePRICE       = "PRICE" + counter;
                            fieldnameDISCOUNT    = "DISCOUNT" + counter;
                            fieldnameCOUPON_CODE = "COUPON_CODE" + counter;
                            fieldnamePAIDPRICE   = "PAID_PRICE_PROD" + counter;
                            fieldnameTAXRATE     = "TAX_RATE" + counter;
                            fieldnameSHIPPING    = "SHIPPING" + counter;
                            xml.WriteElementString(fieldnamePRODUCT, GetSkuCode(sku.SkuId, orderItem.CustomerInfo.ShippingAddress.CountryId));
                            xml.WriteElementString(fieldnameQUANTITY, Item.Quantity.ToString());
                            xml.WriteElementString(fieldnamePRICE, sku.FullPrice.ToString("N2"));
                            xml.WriteElementString(fieldnameTAXRATE, SiteBasePage.CalculateTaxRate(orderItem.OrderId, Item.FullPrice).ToString());

                            if (count == 1)
                            {
                                if (orderCouponInfo.DiscountCode.Length > 0)
                                {
                                    xml.WriteElementString(fieldnamePAIDPRICE, ((sku.InitialPrice * Item.Quantity) - orderCouponInfo.DiscountAmount).ToString("N2"));
                                    xml.WriteElementString(fieldnameDISCOUNT, orderCouponInfo.DiscountAmount.ToString("n2"));
                                    xml.WriteElementString(fieldnameCOUPON_CODE, orderCouponInfo.DiscountCode);
                                }
                                else
                                {
                                    xml.WriteElementString(fieldnamePAIDPRICE, (sku.InitialPrice * Item.Quantity).ToString("N2"));
                                    xml.WriteElementString(fieldnameDISCOUNT, "");
                                    xml.WriteElementString(fieldnameCOUPON_CODE, "");
                                }
                                xml.WriteElementString(fieldnameSHIPPING, orderItem.ShippingCost.ToString("N2"));
                                xml.WriteElementString("PAID_SHIPPING_PROD01", orderItem.ShippingCost.ToString("N2"));
                                xml.WriteElementString("PAID_TAX_PROD01", Math.Round(orderItem.Tax, 2).ToString("N2"));
                            }
                            else
                            {
                                xml.WriteElementString(fieldnamePAIDPRICE, (sku.InitialPrice * Item.Quantity).ToString("N2"));
                                xml.WriteElementString(fieldnameDISCOUNT, "");
                                xml.WriteElementString(fieldnameCOUPON_CODE, "");
                            }
                            count++;
                        }
                    }

                    //if (orderCouponInfo.DiscountCode.Length > 0)
                    //{
                    //    string counter = zeropad(count.ToString(), 2);
                    //    fieldnamePRODUCT = "PRODUCT" + counter;
                    //    fieldnameQUANTITY = "QUANTITY" + counter;
                    //    fieldnamePRICE = "PRICE" + counter;
                    //    fieldnameDISCOUNT = "DISCOUNT" + counter;
                    //    fieldnameCOUPON_CODE = "COUPON_CODE" + counter;
                    //    //fieldnamePAIDPRICE = "PAID_PRICE_PROD" + counter;
                    //    //fieldnameTAXRATE = "TAX_RATE" + counter;
                    //    //fieldnameSHIPPING = "SHIPPING" + counter;
                    //    xml.WriteElementString(fieldnamePRODUCT, orderCouponInfo.DiscountCode);
                    //    xml.WriteElementString(fieldnameQUANTITY, "1");
                    //    xml.WriteElementString(fieldnamePRICE, "0");
                    //    xml.WriteElementString(fieldnameDISCOUNT, orderCouponInfo.DiscountAmount.ToString("n2"));
                    //    xml.WriteElementString(fieldnameCOUPON_CODE, orderCouponInfo.DiscountCode);
                    //    //xml.WriteElementString(fieldnameTAXRATE, "0");
                    //    //xml.WriteElementString(fieldnamePAIDPRICE, "0");
                    //    //if (count == 1)
                    //    //{
                    //    //    //xml.WriteElementString(fieldnameSHIPPING, orderItem.ShippingCost.ToString("N2"));
                    //    //    xml.WriteElementString("PAID_SHIPPING_PROD01", orderItem.ShippingCost.ToString("N2"));
                    //    //    xml.WriteElementString("PAID_TAX_PROD01", Math.Round(orderItem.Tax, 2).ToString("N2"));
                    //    //}
                    //    count++;
                    //}
                    xml.WriteEndElement();
                    xml.WriteStartElement("Settings");
                    xml.WriteElementString("MATCH_FIRST_NAME", "");
                    xml.WriteElementString("MATCH_LAST_NAME", "");
                    xml.WriteElementString("MATCH_ADDRESS", "");
                    xml.WriteElementString("MATCH_ADDRESS_2", "");
                    xml.WriteElementString("MATCH_CITY", "");
                    xml.WriteElementString("MATCH_STATE", "");
                    xml.WriteElementString("MATCH_ZIP", "");
                    xml.WriteElementString("MATCH_PHONE", "");
                    xml.WriteElementString("MATCH_EMAIL", "");
                    xml.WriteElementString("MATCH_CLIENT", "");
                    xml.WriteElementString("MATCH_CAMPAIGN", "");
                    xml.WriteElementString("API_LAYOUT_VERSION", "2");
                    xml.WriteElementString("TAX_CALCULATION_METHOD", "ITEM");
                    xml.WriteEndElement();
                    xml.WriteEndElement();
                    strXml = str.ToString();
                }
            }
            return(strXml);
        }
Пример #15
0
        public void Process(int orderId, Cart cartData,
                            Dictionary <int, int> selectedProducts, // skuId => quantity
                            OrderProcessTypeEnum orderProcessType)
        {
            int totalItems = this.Items.Count;

            //Add Selected PostSell Item to Cart
            if (selectedProducts.Count > 0)
            {
                SkuManager skuManager = new SkuManager();
                // List<Sku> allSkus = skuManager.GetAllSkus();
                foreach (var item in selectedProducts)
                {
                    cartData.AddItem(item.Key, item.Value, true, true);
                }
            }

            //Apply business rules to add or remove items
            for (int i = 0; i < totalItems; i++)
            {
                TemplateSku item = this.Items[i];
                switch (item.TypeId)
                {
                case TemplateItemTypeEnum.Add:
                {
                    cartData.AddItem(item.SkuId, 1, true, true);
                }
                break;

                case TemplateItemTypeEnum.Remove:
                {
                    cartData.RemoveSku(item.SkuId);
                }
                break;

                default:
                    break;
                }
            }

            // If this is a Upsell Review Order type, then we do not want to compute with non-save-to-db SKU's since it will mess up the totals when we want to save just save-to-db SKU's.
            // So, we drop non-save-to-db SKU's prior to computing, and then add them afterwards (so in the final review page we see ALL of the SKU's).
            List <Sku> nonSaveToDbSkus = new List <Sku>();

            if (orderProcessType == OrderProcessTypeEnum.EnableUpsellReviewOrder)
            {
                for (int i = 0; i < cartData.CartItems.Count; i++)
                {
                    if (cartData.CartItems[i].IsUpSell &&
                        !cartData.CartItems[i].GetAttributeValue <bool>("SaveToDatabase", false))
                    {
                        nonSaveToDbSkus.Add(cartData.CartItems[i]);

                        cartData.CartItems.RemoveAt(i);
                        i--;
                    }
                }
            }

            //Commit to database based on the config
            if (orderProcessType == OrderProcessTypeEnum.InstantOrderProcess ||
                orderProcessType == OrderProcessTypeEnum.EnableUpsellReviewOrder)
            {
                cartData.Compute();
                if (orderProcessType != OrderProcessTypeEnum.EnableUpsellReviewOrder)
                {
                    new OrderManager().UpdateOrderAfterUpSell(orderId, cartData);
                }

                foreach (Sku sku in nonSaveToDbSkus)
                {
                    cartData.CartItems.Add(sku);
                }
            }
        }
Пример #16
0
        public PostOrderBatchRequest GetRequest(Order orderItem)
        {
            String strXml = String.Empty;

            orderItem.LoadAttributeValues();

            string ShippingStateProvinceAbbreviation = "";
            string BillingStateProvinceAbbreviation  = "";
            List <StateProvince> states = StateManager.GetAllStates(0);
            StateProvince        itemShippingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.ShippingAddress.StateProvinceId));

            if (itemShippingStateProvince != null)
            {
                ShippingStateProvinceAbbreviation = itemShippingStateProvince.Abbreviation.Trim();
            }
            StateProvince itemBillingStateProvince = states.FirstOrDefault(x => x.StateProvinceId == Convert.ToInt32(orderItem.CustomerInfo.BillingAddress.StateProvinceId));

            if (itemBillingStateProvince != null)
            {
                BillingStateProvinceAbbreviation = itemBillingStateProvince.Abbreviation.Trim();
            }

            Sku ShippingSku = GetShippingSku(orderItem);
            //string ShipCodeService = GetShippingSku(orderItem).SkuCode;

            PostOrderBatchRequest PostOrderBatchRequest1 = new PostOrderBatchRequest();

            InnotracWS.WSAuthorization WSAuthorization1 = new InnotracWS.WSAuthorization();
            WSAuthorization1.Username = config.Attributes["Username"].Value;
            WSAuthorization1.Password = config.Attributes["Password"].Value;
            PostOrderBatchRequest1.WSAuthorization = WSAuthorization1;

            int TransmissionBatchID = 0; // GetTransmissionBatchID();

            PostOrderBatchRequestOrderBatch OrderBatch1 = new PostOrderBatchRequestOrderBatch();

            OrderBatch1.TransmissionBatchID = Convert.ToDouble(TransmissionBatchID);
            OrderBatch1.TransmissionSource  = config.Attributes["TransmissionSource"].Value;
            OrderBatch1.TransmissionDate    = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"));
            OrderBatch1.Telemarketer        = config.Attributes["Telemarketer"].Value;
            OrderBatch1.RerunCount          = Convert.ToInt32(config.Attributes["RerunCount"].Value);
            OrderBatch1.NumberOfOrders      = Convert.ToInt32(config.Attributes["NumberOfOrders"].Value);
            OrderBatch1.CustomerInfoOnly    = config.Attributes["CustomerInfoOnly"].Value;

            PostOrderBatchRequestOrderBatchCustomer Customer = new PostOrderBatchRequestOrderBatchCustomer();

            Customer.SerialID                = config.Attributes["SerialID"].Value;
            Customer.Project                 = Convert.ToInt32(config.Attributes["Project"].Value);
            Customer.CustomerNo              = Convert.ToInt32(config.Attributes["CustomerNo"].Value);
            Customer.CustomerNoSpecified     = true;
            Customer.ClientCustomer          = Convert.ToInt32(config.Attributes["ClientCustomer"].Value);
            Customer.ClientCustomerSpecified = true;
            Customer.FirstName               = orderItem.CustomerInfo.BillingAddress.FirstName;
            Customer.LastName                = orderItem.CustomerInfo.BillingAddress.LastName;
            Customer.Address1                = orderItem.CustomerInfo.BillingAddress.Address1;
            Customer.Address2                = orderItem.CustomerInfo.BillingAddress.Address2;
            Customer.City = orderItem.CustomerInfo.BillingAddress.City;

            Customer.State = BillingStateProvinceAbbreviation; //  orderItem.CustomerInfo.BillingAddress.StateProvinceName;
            Customer.Zip   = orderItem.CustomerInfo.BillingAddress.ZipPostalCode;
            if (orderItem.CustomerInfo.BillingAddress.CountryId == 46)
            {
                Customer.Country = "CN";
            }
            else
            {
                Customer.Country = CountryManager.CountryCode(orderItem.CustomerInfo.BillingAddress.CountryId).Trim();
            }
            Customer.DayPhoneSpecified = true;
            Customer.DayPhone          = Convert.ToDouble(OrderHelper.GetCleanPhoneNumber(orderItem.CustomerInfo.BillingAddress.PhoneNumber));

            PostOrderBatchRequestOrderBatchCustomerEmail CustomerEmail = new PostOrderBatchRequestOrderBatchCustomerEmail();

            CustomerEmail.EmailAddress = orderItem.Email;
            CustomerEmail.EmailFlag    = config.Attributes["EmailFlag"].Value;
            Customer.Email             = new PostOrderBatchRequestOrderBatchCustomerEmail[1];
            Customer.Email[0]          = CustomerEmail;

            Customer.CustomerMailFlag = config.Attributes["CustomerMailFlag"].Value;
            Customer.RentNameFlag     = config.Attributes["RentNameFlag"].Value;
            Customer.OrderEmailsFlag  = config.Attributes["OrderEmailsFlag"].Value;
            string MarketingEmailsFlag = "N";

            //if (orderItem.AttributeValues.ContainsAttribute("sendoffers") && orderItem.AttributeValues["sendoffers"].Value != null)
            //{
            //    if (orderItem.AttributeValues["sendoffers"].Value.Equals("1"))
            //    {
            //        MarketingEmailsFlag = "Y";
            //    }
            //    else
            //    {
            //        MarketingEmailsFlag = "N";
            //    }
            //}
            Customer.MarketingEmailsFlag = MarketingEmailsFlag.ToUpper();
            Customer.Language            = config.Attributes["Language"].Value;

            PostOrderBatchRequestOrderBatchCustomerOrder CustomerOrder = new PostOrderBatchRequestOrderBatchCustomerOrder();

            CustomerOrder.ServiceBeforeShip = config.Attributes["ServiceBeforeShip"].Value;
            CustomerOrder.OrderNo           = Convert.ToInt32(config.Attributes["OrderNo"].Value);
            CustomerOrder.OrderNoSpecified  = true;
            CustomerOrder.PurchaseOrder     = config.Attributes["OrderIdPrefix"].Value + orderItem.OrderId.ToString();
            CustomerOrder.Promotion         = config.Attributes["Promotion"].Value;


            string Media = config.Attributes["MediaCode"].Value;

            //if (orderItem.AttributeValues.ContainsAttribute("mediacode") && orderItem.AttributeValues["mediacode"].Value != null && !orderItem.AttributeValues["mediacode"].Value.Equals(""))
            //{
            //    Media = orderItem.AttributeValues["mediacode"].Value;
            //}
            CustomerOrder.Media = Media;
            //CustomerOrder.BackEndCode = config.Attributes["BackEndCode"].Value;
            CustomerOrder.BaseContinuityOrderFlag = GetContinuityFlag(orderItem);                               // config.Attributes["BaseContinuityOrderFlag"].Value;
            CustomerOrder.OrderCategory           = config.Attributes["OrderCategory"].Value;
            CustomerOrder.OrderDate = Convert.ToDateTime(orderItem.CreatedDate.ToString("yyyy-MM-dd H:mm:ss")); // .ToString("MM/dd/yy hh:mm:ss"));
            // These should instead have a T separating date from time, like this: <inoc:OrderDate>2014-05-13T19:24:02</inoc:OrderDate>
            CustomerOrder.OrderReferenceNo1         = config.Attributes["OrderIdPrefix"].Value + orderItem.OrderId.ToString();
            CustomerOrder.UserId                    = config.Attributes["UserId"].Value;
            CustomerOrder.ShipFeeService            = ShippingSku.SkuCode; // ShipFeeService; //  GetShipFeeService(orderItem);
            CustomerOrder.ShipCodeService           = ShippingSku.SkuCode; // ShipCodeService; // GetShipCodeService(orderItem);
            CustomerOrder.ResidentialCommercialFlag = config.Attributes["ResidentialCommercialFlag"].Value;
            CustomerOrder.PricingCalculationMethod  = config.Attributes["PricingCalculationMethod"].Value;
            CustomerOrder.ShippingCalculationMethod = config.Attributes["ShippingCalculationMethod"].Value;
            CustomerOrder.PaymentPlan               = GetPaymentPlan(orderItem);
            CustomerOrder.Language                  = config.Attributes["Language"].Value;

            PostOrderBatchRequestOrderBatchCustomerOrderOrderShipTo OrderOrderShipTo = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipTo();

            OrderOrderShipTo.ShipToFirstName = orderItem.CustomerInfo.ShippingAddress.FirstName;
            OrderOrderShipTo.ShipToLastName  = orderItem.CustomerInfo.ShippingAddress.LastName;
            OrderOrderShipTo.ShipToAddress1  = orderItem.CustomerInfo.ShippingAddress.Address1;
            OrderOrderShipTo.ShipToAddress2  = orderItem.CustomerInfo.ShippingAddress.Address2;
            OrderOrderShipTo.ShipToCity      = orderItem.CustomerInfo.ShippingAddress.City;
            OrderOrderShipTo.ShipToState     = ShippingStateProvinceAbbreviation; // orderItem.CustomerInfo.ShippingAddress.StateProvinceName;
            OrderOrderShipTo.ShipToZip       = orderItem.CustomerInfo.ShippingAddress.ZipPostalCode;
            if (orderItem.CustomerInfo.ShippingAddress.CountryId == 46)
            {
                OrderOrderShipTo.ShipToCountry = "CN";
            }
            else
            {
                OrderOrderShipTo.ShipToCountry = CountryManager.CountryCode(orderItem.CustomerInfo.ShippingAddress.CountryId).Trim();
            }
            OrderOrderShipTo.ShipFeeService  = ShippingSku.SkuCode; // GetShipFeeService(orderItem);
            OrderOrderShipTo.ShipCodeService = ShippingSku.SkuCode; // GetShipCodeService(orderItem);

            OrderOrderShipTo.OrderItems = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItems[orderItem.SkuItems.Count];
            PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItems OrderShipToOrderItems;
            int        LineNo       = 1;
            int        arrayCounter = 0;
            decimal    ItemPrice    = 0;
            SkuManager skuManager   = new SkuManager();
            List <Sku> SkuItems1    = new List <Sku>();

            foreach (Sku Item in orderItem.SkuItems)
            {
                // Add BASE SKU for Sending to Innotrac
                //if (skuManager.GetSkuByID(Item.SkuId).CategoryId == 1)
                //{
                SkuItems1.Add(Item);
                //}
            }
            // Add FREEGIFT at LAST for SEnding to Innotrac
            //foreach (Sku Item in orderItem.SkuItems)
            //{
            //    // FREEGIFT CategoryId 16
            //    if (skuManager.GetSkuByID(Item.SkuId).CategoryId == 16)
            //    {
            //        SkuItems1.Add(Item);
            //    }
            //}
            foreach (Sku Item in SkuItems1)
            {
                //if (skuManager.GetSkuByID(Item.SkuId).CategoryId == 1)
                //{
                //ItemPricing ItemPricing1 = ItemPricingBySkuID[Item.SkuId];
                OrderShipToOrderItems     = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItems();
                OrderShipToOrderItems.SKU = Item.SkuCode;
                //if (orderItem.CustomerInfo.ShippingAddress.CountryId == 46)
                //{
                //    Item.LoadAttributeValues();
                //    if (Item.GetAttributeValue<string>("skucode_canada", string.Empty) != string.Empty)
                //    {
                //        OrderShipToOrderItems.SKU = Item.GetAttributeValue<string>("skucode_canada", string.Empty);
                //    }
                //}
                OrderShipToOrderItems.Quantity            = Item.Quantity;
                OrderShipToOrderItems.LineNumber          = LineNo;
                OrderShipToOrderItems.LineNumberSpecified = true;

                PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItemsItemPricing OrderItemsItemPricing = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipToOrderItemsItemPricing();
                ItemPrice = 0;
                ItemPrice = Item.FullPrice * Item.Quantity;
                //Pass P for PricingCalculationMethod (M). you need to remove the ItemPricing section, since we will be calculating each of the prices for you, at the line level.
                //OrderItemsItemPricing.ExtendedPrice = Convert.ToDecimal(ItemPrice.ToString("N2"));
                //OrderItemsItemPricing.ExtendedPriceSpecified = true;
                //OrderItemsItemPricing.ExtendedShipFee =(decimal)0;//ItemPricing1.SKU_Shipping_Price.ToString("N2"));
                //OrderItemsItemPricing.ExtendedShipFeeSpecified = true;
                //OrderItemsItemPricing.ExtendedTax = GetSkuTaxCost(orderItem.CustomerInfo.ShippingAddress, Item);// ItemPricing1.SKU_Total_Tax.ToString("N2"));
                //OrderItemsItemPricing.ExtendedTaxSpecified = true;
                OrderShipToOrderItems.ItemPricing         = OrderItemsItemPricing;
                OrderOrderShipTo.OrderItems[arrayCounter] = OrderShipToOrderItems;
                LineNo++;
                arrayCounter++;
                // }
            }

            // IF order contains more than one unique SKU -AND- is trying to do an install payment, flag as 'Y'
            //string InstallPaymentPlanCode = config.Attributes["InstallPaymentPlanCode"].Value.ToUpper();
            //if (LineNo > 2 && CustomerOrder.PaymentPlan.ToUpper().Equals(InstallPaymentPlanCode))
            //{
            //    CustomerOrder.ServiceBeforeShip = "Y";
            //}
            //else
            //{
            CustomerOrder.ServiceBeforeShip = config.Attributes["ServiceBeforeShip"].Value;
            //}

            CustomerOrder.OrderShipTo    = new PostOrderBatchRequestOrderBatchCustomerOrderOrderShipTo[1];
            CustomerOrder.OrderShipTo[0] = OrderOrderShipTo;

            PostOrderBatchRequestOrderBatchCustomerOrderPayment           OrderPayment      = new PostOrderBatchRequestOrderBatchCustomerOrderPayment();
            PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCard PaymentCreditCard = new PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCard();

            PaymentCreditCard.SequenceNo       = Convert.ToInt32(config.Attributes["SequenceNo"].Value);
            PaymentCreditCard.CreditCardNumber = orderItem.CreditInfo.CreditCardNumber;
            PaymentCreditCard.ExpirationDate   = orderItem.CreditInfo.CreditCardExpired.ToString("MMyy");
            if ((orderItem.CustomerInfo.BillingAddress.Address1.Equals(orderItem.CustomerInfo.ShippingAddress.Address1)) && (orderItem.CustomerInfo.BillingAddress.City.Equals(orderItem.CustomerInfo.ShippingAddress.City)) &&
                (orderItem.CustomerInfo.BillingAddress.ZipPostalCode.Equals(orderItem.CustomerInfo.ShippingAddress.ZipPostalCode)))
            {
                PaymentCreditCard.CardHolderFlag = CardHolderFlag.S; // If Bill To Address = Ship To Address, then S - Otherwise M
            }
            else
            {
                PaymentCreditCard.CardHolderFlag = CardHolderFlag.M; // If Bill To Address = Ship To Address, then S - Otherwise M
            }
            PaymentCreditCard.CVV2Code = "";

            PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCardBillingAddress CreditCardBillingAddress = new PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCardBillingAddress();

            CreditCardBillingAddress.BillingFirstName = orderItem.CustomerInfo.BillingAddress.FirstName;
            CreditCardBillingAddress.BillingLastName  = orderItem.CustomerInfo.BillingAddress.LastName;
            CreditCardBillingAddress.BillingAddress1  = orderItem.CustomerInfo.BillingAddress.Address1;
            CreditCardBillingAddress.BillingAddress2  = orderItem.CustomerInfo.BillingAddress.Address2;
            CreditCardBillingAddress.BillingCity      = orderItem.CustomerInfo.BillingAddress.City;
            CreditCardBillingAddress.BillingState     = BillingStateProvinceAbbreviation; // orderItem.CustomerInfo.BillingAddress.StateProvinceName;
            CreditCardBillingAddress.BillingZip       = orderItem.CustomerInfo.BillingAddress.ZipPostalCode;
            if (orderItem.CustomerInfo.BillingAddress.CountryId == 46)
            {
                CreditCardBillingAddress.BillingCountry = "CN";
            }
            else
            {
                CreditCardBillingAddress.BillingCountry = orderItem.CustomerInfo.BillingAddress.CountryCode.Trim();
            }
            PaymentCreditCard.BillingAddress = CreditCardBillingAddress;
            OrderPayment.CreditCard          = new PostOrderBatchRequestOrderBatchCustomerOrderPaymentCreditCard[1];
            OrderPayment.CreditCard[0]       = PaymentCreditCard;
            OrderPayment.CurrencyCode        = config.Attributes["CurrencyCode"].Value;
            CustomerOrder.Payment            = OrderPayment;

            PostOrderBatchRequestOrderBatchCustomerOrderOrderSourceTotals OrderOrderSourceTotals = new PostOrderBatchRequestOrderBatchCustomerOrderOrderSourceTotals();
            decimal SubTotalFullPrice_ContinuityProducts = 0;                                                                                                      // GetFullPriceSubTotal_ContinuitySKU(orderItem);

            OrderOrderSourceTotals.ProductTotal = Convert.ToDecimal(String.Format("{0:.00}", orderItem.FullPriceSubTotal - SubTotalFullPrice_ContinuityProducts)); // SubTotal)); // FullPriceSubTotal));
            if (orderItem.CustomerInfo.ShippingAddress.CountryId == 46)
            {
                // setup the tax as a flat 10% for Canadian orders
                // it would be best if you sent the 10 percent charge as S&H as that is the way we display it in our CRM and the customer pack slip.
                OrderOrderSourceTotals.TaxTotal     = Convert.ToDecimal(String.Format("{0:.00}", "0.00"));
                OrderOrderSourceTotals.ShipFeeTotal = orderItem.ShippingCost + orderItem.AdditionalShippingCharge + orderItem.FullPriceTax;
            }
            else
            {
                OrderOrderSourceTotals.TaxTotal     = Convert.ToDecimal(String.Format("{0:.00}", orderItem.FullPriceTax));
                OrderOrderSourceTotals.ShipFeeTotal = orderItem.ShippingCost + orderItem.AdditionalShippingCharge;  // ShippingSku.FullPrice + orderItem.AdditionalShippingCharge;// Convert.ToDecimal(String.Format("{0:.00}", orderItem.ShippingCost));
            }
            OrderOrderSourceTotals.GiftCertificateTotalSpecified = true;
            OrderOrderSourceTotals.GiftCertificateTotal          = 0;
            CustomerOrder.OrderSourceTotals = OrderOrderSourceTotals;
            CustomerOrder.ShipCompleteFlag  = "";
            Customer.Order                    = new PostOrderBatchRequestOrderBatchCustomerOrder[1];
            Customer.Order[0]                 = CustomerOrder;
            OrderBatch1.Customer              = new PostOrderBatchRequestOrderBatchCustomer[1];
            OrderBatch1.Customer[0]           = Customer;
            PostOrderBatchRequest1.OrderBatch = OrderBatch1;
            return(PostOrderBatchRequest1); // strXml;
        }